Пример #1
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            string url = "/Mobile/CheckOut.html";
            //检查地址
            string consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));

            if (consignee == string.Empty)
            {
                ScriptHelper.AlertFront("收货人姓名不能为空", url);
            }
            string tel    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
            string mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));

            if (tel == string.Empty && mobile == string.Empty)
            {
                ScriptHelper.AlertFront("固定电话,手机必须得填写一个", url);
            }
            string zipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode"));
            string address = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));

            if (address == string.Empty)
            {
                ScriptHelper.AlertFront("地址不能为空", url);
            }
            //验证配送方式
            int shippingID = RequestHelper.GetForm <int>("ShippingID");

            if (shippingID == int.MinValue)
            {
                ScriptHelper.AlertFront("请选择配送方式", url);
            }
            //检查支付方式
            string payKey = RequestHelper.GetForm <string>("Pay");

            if (string.IsNullOrEmpty(payKey))
            {
                ScriptHelper.AlertFront("请选择付款方式", url);
            }
            PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey);
            //检查金额
            decimal productMoney = 0, pointMoney = 0;
            var     user = UserBLL.ReadUserMore(base.UserId);

            #region 计算订单金额
            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();
            if (cartList.Count < 1)
            {
                ResponseHelper.Redirect("/Mobile/cart.html");
                ResponseHelper.End();
            }

            //关联的商品
            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);
                    int leftStorageCount = standardRecord.Storage - OrderDetailBLL.GetOrderCount(cart.ProductId, cart.StandardValueList);
                    if (leftStorageCount >= cart.BuyCount)
                    {
                        cart.Price            = standardRecord.SalePrice;
                        cart.LeftStorageCount = leftStorageCount;
                        //规格集合
                        cart.Standards = ProductTypeStandardBLL.ReadList(Array.ConvertAll <string, int>(standardRecord.StandardIdList.Split(';'), k => Convert.ToInt32(k)));
                    }
                    else
                    {
                        ScriptHelper.AlertFront("您购物车中 " + cart.Product.Name + " 库存不足,请重新选择", "/Mobile/Cart.html");
                    }
                }
                else
                {
                    int leftStorageCount = cart.Product.TotalStorageCount - OrderDetailBLL.GetOrderCount(cart.ProductId, cart.StandardValueList);
                    if (leftStorageCount >= cart.BuyCount)
                    {
                        cart.Price            = cart.Product.SalePrice;
                        cart.LeftStorageCount = leftStorageCount;
                    }
                    else
                    {
                        ScriptHelper.AlertFront("您购物车中 " + cart.Product.Name + " 库存不足,请重新选择", "/Mobile/Cart.html");
                    }
                }
            }
            #endregion
            productMoney = cartList.Sum(k => k.BuyCount * k.Price);


            decimal shippingMoney = 0;
            //订单优惠活动
            var favor = new FavorableActivityInfo {
                Id = RequestHelper.GetForm <int>("FavorableActivity")
            };
            //商品优惠
            var productfavor = new FavorableActivityInfo {
                Id = RequestHelper.GetForm <int>("ProductFavorableActivity")
            };
            #region 计算运费
            string regionID = RequestHelper.GetForm <string>("RegionID");
            //计算配送费用
            ShippingInfo       shipping       = ShippingBLL.Read(shippingID);
            ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shippingID, regionID);
            switch (shipping.ShippingType)
            {
            case (int)ShippingType.Fixed:
                shippingMoney = shippingRegion.FixedMoeny;
                break;

            case (int)ShippingType.Weight:
                decimal cartProductWeight = Sessions.ProductTotalWeight;
                if (cartProductWeight <= shipping.FirstWeight)
                {
                    shippingMoney = shippingRegion.FirstMoney;
                }
                else
                {
                    shippingMoney = shippingRegion.FirstMoney + Math.Ceiling((cartProductWeight - shipping.FirstWeight) / shipping.AgainWeight) * shippingRegion.AgainMoney;
                }
                break;

            case (int)ShippingType.ProductCount:
                int cartProductCount = Sessions.ProductBuyCount;
                shippingMoney = shippingRegion.OneMoeny + (cartProductCount - 1) * shippingRegion.AnotherMoeny;
                break;

            default:
                break;
            }
            #endregion

            //decimal balance = RequestHelper.GetForm<decimal>("Balance");
            //moneyLeft = UserBLL.ReadUserMore(base.UserId).MoneyLeft;
            //if (balance > moneyLeft)
            //{
            //    balance = 0;
            //    ScriptHelper.AlertFront("金额有错误,请重新检查", url);
            //}
            #region 如果开启了:使用积分抵现,计算积分抵现的现金金额
            //输入的兑换积分数
            var costPoint = RequestHelper.GetForm <int>("costPoint");
            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        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
                        {
                            ScriptHelper.AlertFront("结算金额小于该优惠券要求的最低消费的金额", url);
                        }
                    }
                }
            }
            #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 = products.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(regionID, favor.RegionId))
                    {
                        favorableMoney += shippingMoney;
                    }
                }
            }
            #endregion
            /*-----------应付总价---------------------------------------------------*/
            decimal payMoney = productMoney + shippingMoney - couponMoney - pointMoney - favorableMoney - productfavorableMoney;
            //if (productMoney - favorableMoney + shippingMoney - balance - couponMoney <= 0)
            if (payMoney < 0)
            {
                ScriptHelper.AlertFront("金额有错误,请重新检查", url);
            }

            //添加订单
            OrderInfo order = new OrderInfo();
            order.OrderNumber = ShopCommon.CreateOrderNumber();
            order.IsActivity  = (int)BoolType.False;
            if (payMoney == 0 || payPlugins.IsCod == (int)BoolType.True)
            {
                order.OrderStatus = (int)OrderStatus.WaitCheck;
            }
            else
            {
                order.OrderStatus = (int)OrderStatus.WaitPay;
            }
            order.OrderNote      = string.Empty;
            order.ProductMoney   = productMoney;
            order.Balance        = 0;
            order.FavorableMoney = favorableMoney + productfavorableMoney;
            order.OtherMoney     = 0;
            order.CouponMoney    = couponMoney;
            order.Point          = costPoint;
            order.PointMoney     = pointMoney;
            order.Consignee      = consignee;
            SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass();
            order.RegionId = singleUnlimitClass.ClassID;
            order.Address  = address;
            order.ZipCode  = zipCode;
            order.Tel      = tel;
            if (base.UserId == 0)
            {
                order.Email = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
            }
            else
            {
                order.Email = CookiesHelper.ReadCookieValue("UserEmail");
            }
            order.Mobile              = mobile;
            order.ShippingId          = shippingID;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = shippingMoney;
            order.PayKey              = payKey;
            order.PayName             = payPlugins.Name;
            order.PayDate             = RequestHelper.DateNow;;
            order.IsRefund            = (int)BoolType.False;
            order.FavorableActivityId = RequestHelper.GetForm <int>("FavorableActivityID");
            order.GiftId              = RequestHelper.GetForm <int>("GiftID");
            order.InvoiceTitle        = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceTitle"));
            order.InvoiceContent      = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceContent"));
            order.UserMessage         = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserMessage"));
            order.AddDate             = RequestHelper.DateNow;
            order.IP          = ClientHelper.IP;
            order.UserId      = base.UserId;
            order.UserName    = base.UserName;
            order.GiftMessige = RequestHelper.GetForm <string>("GiftMessige");
            order.IsNoticed   = 0;

            int orderID = OrderBLL.Add(order);
            //使用余额

            /*if (balance > 0)
             * {
             *  UserAccountRecordInfo userAccountRecord = new UserAccountRecordInfo();
             *  userAccountRecord.Money = -balance;
             *  userAccountRecord.Point = 0;
             *  userAccountRecord.Date = RequestHelper.DateNow;
             *  userAccountRecord.IP = ClientHelper.IP;
             *  userAccountRecord.Note = "支付订单:";
             *  userAccountRecord.UserId = base.UserId;
             *  userAccountRecord.UserName = base.UserName;
             *  UserAccountRecordBLL.Add(userAccountRecord);
             * }*/
            #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
            #region 使用优惠券
            string strUserCoupon = RequestHelper.GetForm <string>("UserCoupon");
            if (couponMoney > 0 && !string.IsNullOrEmpty(strUserCoupon) && strUserCoupon != "0|0")
            {
                userCoupon.IsUse   = (int)BoolType.True;
                userCoupon.OrderId = orderID;
                UserCouponBLL.Update(userCoupon);
            }
            #endregion
            AddOrderProduct(orderID);
            //更改产品库存订单数量
            ProductBLL.ChangeOrderCountByOrder(orderID, ChangeAction.Plus);
            /*----------------------------------------------------------------------*/

            ResponseHelper.Redirect("/Mobile/Finish-I" + orderID.ToString() + ".html");
        }
Пример #2
0
        protected override void PostBack()
        {
            string url  = "/CheckOut.aspx";
            string str2 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));

            if (str2 == string.Empty)
            {
                ScriptHelper.Alert("收货人姓名不能为空", url);
            }
            string str3 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
            string str4 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));

            if ((str3 == string.Empty) && (str4 == string.Empty))
            {
                ScriptHelper.Alert("固定电话,手机必须得填写一个", url);
            }
            string str5 = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode"));

            if (str5 == string.Empty)
            {
                ScriptHelper.Alert("邮编不能为空", url);
            }
            string str6 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));

            if (str6 == string.Empty)
            {
                ScriptHelper.Alert("地址不能为空", url);
            }
            int form = RequestHelper.GetForm <int>("ShippingID");

            if (form == -2147483648)
            {
                ScriptHelper.Alert("请选择配送方式", url);
            }
            decimal productTotalPrice = Sessions.ProductTotalPrice;
            decimal num3 = RequestHelper.GetForm <decimal>("FavorableMoney");
            decimal num4 = RequestHelper.GetForm <decimal>("ShippingMoney");
            decimal num5 = RequestHelper.GetForm <decimal>("Balance");
            decimal num6 = RequestHelper.GetForm <decimal>("CouponMoney");

            if (((((productTotalPrice - num3) + num4) - num5) - num6) < 0M)
            {
                ScriptHelper.Alert("金额有错误,请重新检查", url);
            }
            string         key   = RequestHelper.GetForm <string>("Pay");
            PayPluginsInfo info  = PayPlugins.ReadPayPlugins(key);
            OrderInfo      order = new OrderInfo();

            order.OrderNumber = ShopCommon.CreateOrderNumber();
            order.IsActivity  = 0;
            if ((((((productTotalPrice - num3) + num4) - num5) - num6) == 0M) || (info.IsCod == 1))
            {
                order.OrderStatus = 2;
            }
            else
            {
                order.OrderStatus = 1;
            }
            order.OrderNote      = string.Empty;
            order.ProductMoney   = productTotalPrice;
            order.Balance        = num5;
            order.FavorableMoney = num3;
            order.OtherMoney     = 0M;
            order.CouponMoney    = num6;
            order.Consignee      = str2;
            SingleUnlimitClass class2 = new SingleUnlimitClass();

            order.RegionID = class2.ClassID;
            order.Address  = str6;
            order.ZipCode  = str5;
            order.Tel      = str3;
            if (base.UserID == 0)
            {
                order.Email = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
            }
            else
            {
                order.Email = CookiesHelper.ReadCookieValue("UserEmail");
            }
            order.Mobile              = str4;
            order.ShippingID          = form;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = num4;
            order.PayKey              = key;
            order.PayName             = info.Name;
            order.PayDate             = RequestHelper.DateNow;
            order.IsRefund            = 0;
            order.FavorableActivityID = RequestHelper.GetForm <int>("FavorableActivityID");
            order.GiftID              = RequestHelper.GetForm <int>("GiftID");
            order.InvoiceTitle        = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceTitle"));
            order.InvoiceContent      = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceContent"));
            order.UserMessage         = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserMessage"));
            order.AddDate             = RequestHelper.DateNow;
            order.IP       = ClientHelper.IP;
            order.UserID   = base.UserID;
            order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            if (num5 > 0M)
            {
                UserAccountRecordBLL.AddUserAccountRecord(-num5, 0, "支付订单:" + order.OrderNumber, base.UserID, base.UserName);
            }
            string str8 = RequestHelper.GetForm <string>("UserCoupon");

            if ((num6 > 0M) && (str8 != "0|0"))
            {
                UserCouponInfo userCoupon = UserCouponBLL.ReadUserCoupon(Convert.ToInt32(str8.Split(new char[] { '|' })[0]), base.UserID);
                userCoupon.IsUse   = 1;
                userCoupon.OrderID = orderID;
                UserCouponBLL.UpdateUserCoupon(userCoupon);
            }
            this.AddOrderProduct(orderID);
            ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);
            ResponseHelper.Redirect("/Finish-I" + orderID.ToString() + ".aspx");
        }
Пример #3
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            int groupID = RequestHelper.GetForm <int>("groupID");

            buyCount = RequestHelper.GetForm <int>("buyCount");
            string url = "/GroupBuyOrder-" + groupID + "-" + buyCount + ".aspx";

            groupBuy = GroupBuyBLL.ReadGroupBuy(groupID);
            if (groupBuy.ID <= 0)
            {
                ScriptHelper.AlertFront("该团购不存在!", url);
            }
            if (UserGroupBuyBLL.ReadUserGroupBuyByUser(groupID, base.UserID).ID > 0)
            {
                ScriptHelper.AlertFront("您已经参加该团购了!", url);
            }
            if (groupBuy.StartDate > DateTime.Now)
            {
                ScriptHelper.AlertFront("该团购还未开始,不能购买!", url);
            }
            if (groupBuy.EndDate < DateTime.Now)
            {
                ScriptHelper.AlertFront("该团购已经结束,不能购买!", url);
            }
            if (buyCount <= 0)
            {
                ScriptHelper.AlertFront("购买数量有误!", url);
            }
            if (buyCount > groupBuy.EachNumber)
            {
                ScriptHelper.AlertFront("购买数量超过了该团购个人限购数!", url);
            }
            int hasBuy = 0;

            foreach (UserGroupBuyInfo userGroupBuy in UserGroupBuyBLL.ReadUserGroupBuyList(groupID))
            {
                hasBuy += userGroupBuy.BuyCount;
            }
            if (buyCount > (groupBuy.MaxCount - hasBuy))
            {
                ScriptHelper.AlertFront("购买数量超过了该团购剩余数!", url);
            }
            product = ProductBLL.ReadProduct(groupBuy.ProductID);

            //检查地址
            string consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));

            if (consignee == string.Empty)
            {
                ScriptHelper.AlertFront("收货人姓名不能为空", url);
            }
            string tel    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
            string mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));

            if (tel == string.Empty && mobile == string.Empty)
            {
                ScriptHelper.AlertFront("固定电话,手机必须得填写一个", url);
            }
            string zipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode"));

            if (zipCode == string.Empty)
            {
                ScriptHelper.AlertFront("邮编不能为空", url);
            }
            string address = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));

            if (address == string.Empty)
            {
                ScriptHelper.AlertFront("地址不能为空", url);
            }
            //验证配送方式
            int shippingID = RequestHelper.GetForm <int>("ShippingID");

            if (shippingID == int.MinValue)
            {
                ScriptHelper.AlertFront("请选择配送方式", url);
            }
            //检查金额
            decimal productMoney   = groupBuy.Price * buyCount;
            decimal favorableMoney = RequestHelper.GetForm <decimal>("FavorableMoney");
            decimal shippingMoney  = RequestHelper.GetForm <decimal>("ShippingMoney");
            decimal balance        = RequestHelper.GetForm <decimal>("Balance");
            decimal couponMoney    = RequestHelper.GetForm <decimal>("CouponMoney");

            if (productMoney - favorableMoney + shippingMoney - balance - couponMoney < 0)
            {
                ScriptHelper.AlertFront("金额有错误,请重新检查", url);
            }
            //支付方式
            string         payKey     = RequestHelper.GetForm <string>("Pay");
            PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey);
            //添加订单
            OrderInfo order = new OrderInfo();

            order.OrderNumber = ShopCommon.CreateOrderNumber();
            order.IsActivity  = (int)BoolType.True;
            if (productMoney - favorableMoney + shippingMoney - balance - couponMoney == 0 || payPlugins.IsCod == (int)BoolType.True)
            {
                order.OrderStatus = (int)OrderStatus.WaitCheck;
            }
            else
            {
                order.OrderStatus = (int)OrderStatus.WaitPay;
            }
            order.OrderNote      = "团购活动:" + groupBuy.Name;
            order.ProductMoney   = productMoney;
            order.Balance        = balance;
            order.FavorableMoney = favorableMoney;
            order.OtherMoney     = 0;
            order.CouponMoney    = couponMoney;
            order.Consignee      = consignee;
            SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass();

            order.RegionID = singleUnlimitClass.ClassID;
            order.Address  = address;
            order.ZipCode  = zipCode;
            order.Tel      = tel;
            string userEmail = string.Empty;

            if (base.UserID == 0)
            {
                userEmail = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
            }
            else
            {
                userEmail = CookiesHelper.ReadCookieValue("UserEmail");
            }
            order.Email               = userEmail;
            order.Mobile              = mobile;
            order.ShippingID          = shippingID;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = shippingMoney;
            order.PayKey              = payKey;
            order.PayName             = payPlugins.Name;
            order.PayDate             = RequestHelper.DateNow;;
            order.IsRefund            = (int)BoolType.False;
            order.FavorableActivityID = 0;
            order.GiftID              = 0;
            order.InvoiceTitle        = string.Empty;
            order.InvoiceContent      = string.Empty;
            order.UserMessage         = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserMessage"));
            order.AddDate             = RequestHelper.DateNow;
            order.IP       = ClientHelper.IP;
            order.UserID   = base.UserID;
            order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            OrderDetailInfo orderDetail = new OrderDetailInfo();

            orderDetail.OrderID       = orderID;
            orderDetail.ProductID     = product.ID;
            orderDetail.ProductName   = product.Name;
            orderDetail.ProductWeight = product.Weight;
            orderDetail.SendPoint     = 0;
            orderDetail.ProductPrice  = groupBuy.Price;
            orderDetail.BuyCount      = buyCount;
            orderDetail.FatherID      = 0;
            orderDetail.RandNumber    = string.Empty;
            orderDetail.GiftPackID    = 0;
            OrderDetailBLL.AddOrderDetail(orderDetail);
            //更改产品库存订单数量
            ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);

            //添加团购单
            UserGroupBuyInfo buyInfo = new UserGroupBuyInfo();

            buyInfo.GroupBuyID = groupBuy.ID;
            buyInfo.Date       = RequestHelper.DateNow;
            buyInfo.IP         = ClientHelper.IP;
            buyInfo.BuyCount   = buyCount;
            buyInfo.OrderID    = orderID;
            buyInfo.UserID     = base.UserID;
            buyInfo.UserName   = base.UserName;
            buyInfo.Consignee  = consignee;
            buyInfo.RegionID   = singleUnlimitClass.ClassID;
            buyInfo.Address    = address;
            buyInfo.ZipCode    = zipCode;
            buyInfo.Tel        = tel;
            buyInfo.Email      = userEmail;
            buyInfo.Mobile     = mobile;
            UserGroupBuyBLL.AddUserGroupBuy(buyInfo);

            ResponseHelper.Redirect("/Finish-I" + orderID.ToString() + ".aspx");
        }
Пример #4
0
        private void Submit()
        {
            string urlPrefix = string.IsNullOrEmpty(isMobile) ? "/user" : "/mobile";

            if (base.UserId < 1)
            {
                ResponseHelper.Write("error|登录状态已过期,请重新登录|" + urlPrefix + "/login.html");
                ResponseHelper.End();
            }

            int orderId = RequestHelper.GetForm <int>("orderId");

            if (ProductCommentBLL.HasCommented(orderId, base.UserId))
            {
                ResponseHelper.Write("error|订单已评价|" + urlPrefix + "/userproductcomment.html");
                ResponseHelper.End();
            }

            order = OrderBLL.Read(orderId, base.UserId);
            if (order.Id < 1)
            {
                ResponseHelper.Write("error|订单不存在|" + urlPrefix + "/order.html");
                ResponseHelper.End();
            }

            orderDetailList = OrderDetailBLL.ReadList(orderId);

            List <ProductCommentInfo> productCommentList = new List <ProductCommentInfo>();

            foreach (OrderDetailInfo orderDetail in orderDetailList)
            {
                int    rank    = RequestHelper.GetForm <int>("rank_" + orderDetail.ProductId);
                string content = StringHelper.AddSafe(RequestHelper.GetForm <string>("content_" + orderDetail.ProductId));

                if (rank >= 1 && rank <= 5 && !string.IsNullOrEmpty(content))
                {
                    ProductCommentInfo productComment = new ProductCommentInfo();
                    productComment.ProductId         = orderDetail.ProductId;
                    productComment.Title             = "";
                    productComment.Content           = content;
                    productComment.UserIP            = ClientHelper.IP;
                    productComment.PostDate          = RequestHelper.DateNow;
                    productComment.Support           = 0;
                    productComment.Against           = 0;
                    productComment.Status            = ShopConfig.ReadConfigInfo().CommentDefaultStatus;
                    productComment.Rank              = rank;
                    productComment.ReplyCount        = 0;
                    productComment.AdminReplyContent = string.Empty;
                    productComment.AdminReplyDate    = RequestHelper.DateNow;
                    productComment.UserId            = base.UserId;
                    productComment.UserName          = base.UserName;
                    productComment.OrderId           = order.Id;
                    productComment.BuyDate           = order.AddDate;

                    productCommentList.Add(productComment);
                }
                else
                {
                    ResponseHelper.Write("error|评价失败|" + urlPrefix + "/userproductcommentAdd.html?orderid=" + order.Id);
                    ResponseHelper.End();
                }
            }

            foreach (ProductCommentInfo comment in productCommentList)
            {
                ProductCommentBLL.Add(comment);
            }

            ResponseHelper.Write("ok|评价成功|" + urlPrefix + "/userproductcomment.html");
            ResponseHelper.End();
        }
Пример #5
0
        protected override void PageLoad()
        {
            base.PageLoad();

            string action = RequestHelper.GetQueryString <string>("Action");

            if (action == "SelectShipping")
            {
                this.SelectShipping();
            }

            string regionId = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("regionId"));

            //取出所有配送方式Id
            List <ShippingInfo> tempShippingList = ShippingBLL.ReadList();

            tempShippingList = tempShippingList.Where(k => k.IsEnabled == (int)BoolType.True).ToList();

            var shippingIds = new List <int>();

            tempShippingList.ForEach(k => shippingIds.Add(k.Id));

            //读取配送区域列表
            List <ShippingRegionInfo> shippingRegionList = ShippingRegionBLL.ReadList(shippingIds.ToArray());

            #region 读取购物车结算金额
            string checkCart = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart"));
            int[]  cartIds   = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
            if (string.IsNullOrEmpty(checkCart) || cartIds.Length < 1)
            {
                ResponseHelper.Write("error|请选择需要购买的商品");
                ResponseHelper.End();
            }
            //计算配送费用
            List <CartInfo> cartList = CartBLL.ReadList(base.UserId).Where(k => cartIds.Contains(k.Id)).ToList();
            if (cartList.Count < 1)
            {
                ResponseHelper.Write("error|请选择需要购买的商品");
                ResponseHelper.End();
            }
            int count = 0;
            //购物车结算金额
            decimal cartTotalPrice = 0;
            int[]   ids            = cartList.Select(k => k.ProductId).ToArray();
            var     productList    = ProductBLL.SearchList(1, ids.Length, new ProductSearchInfo {
                InProductId = string.Join(",", ids)
            }, ref count);
            cartList.ForEach(k => k.Product = productList.FirstOrDefault(k2 => k2.Id == k.ProductId) ?? new ProductInfo());
            foreach (var cart in cartList)
            {
                if (!string.IsNullOrEmpty(cart.StandardValueList))
                {
                    //使用规格的价格和库存
                    var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList);
                    cartTotalPrice += ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID) * cart.BuyCount;
                }
                else
                {
                    cartTotalPrice += ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID) * cart.BuyCount;
                }
            }
            #endregion
            #region 获取符合条件(时间段,用户等级,金额限制)的整站订单优惠活动列表,默认使用第一个
            favorableActivityList = FavorableActivityBLL.ReadList(DateTime.Now, DateTime.Now).Where <FavorableActivityInfo>(f => f.Type == (int)FavorableType.AllOrders && ("," + f.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && cartTotalPrice >= f.OrderProductMoney).ToList();
            #endregion
            //查找符合条件的配送方式
            foreach (ShippingInfo shipping in tempShippingList)
            {
                string tempRegionId = regionId;
                while (tempRegionId.Length >= 1)
                {
                    bool isFind = false;
                    foreach (ShippingRegionInfo temp in shippingRegionList)
                    {
                        if (("|" + temp.RegionId + "|").IndexOf("|" + tempRegionId + "|") > -1 && temp.ShippingId == shipping.Id)
                        {
                            isFind = true;
                            shippingList.Add(shipping);
                            break;
                        }
                    }
                    if (isFind)
                    {
                        break;
                    }
                    else
                    {
                        tempRegionId = tempRegionId.Substring(0, tempRegionId.Length - 1);
                        tempRegionId = tempRegionId.Substring(0, tempRegionId.LastIndexOf('|') + 1);
                    }
                }
            }
        }
Пример #6
0
        protected void Submit()
        {
            string             userName           = base.UserName;
            string             userEmail          = CookiesHelper.ReadCookieValue("UserEmail");
            SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass();

            //检测积分
            int id = RequestHelper.GetForm <int>("updateId");

            if (id < 1)
            {
                ResponseHelper.Write("error|无效的请求");
                ResponseHelper.End();
            }
            if (singleUnlimitClass.ClassID.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Length < 3)
            {
                ResponseHelper.Write("error|请填写完整的地区信息");
                ResponseHelper.End();
                ResponseHelper.End();
            }

            var pointLeft = UserAccountRecordBLL.SumPoint(base.UserId);

            Gift = PointProductBLL.Read(id);
            if (Gift.Point > pointLeft)
            {
                ResponseHelper.Write("error|您当前的积分不足以兑取该礼品");
                ResponseHelper.End();
            }
            //库存
            int num = RequestHelper.GetForm <int>("num");

            if (num > (Gift.TotalStorageCount - Gift.SendCount))
            {
                ResponseHelper.Write("error|该礼品库存不足");
                ResponseHelper.End();
            }

            //添加订单
            OrderInfo order = new OrderInfo();

            order.OrderNumber         = ShopCommon.CreateOrderNumber();
            order.IsActivity          = (int)BoolType.True;
            order.OrderStatus         = (int)OrderStatus.WaitCheck;
            order.OrderNote           = "积分兑换奖品";
            order.ProductMoney        = 0;
            order.Balance             = 0;
            order.FavorableMoney      = 0;
            order.OtherMoney          = 0;
            order.CouponMoney         = 0;
            order.Consignee           = StringHelper.AddSafe(RequestHelper.GetForm <string>("username"));
            order.RegionId            = singleUnlimitClass.ClassID;
            order.Address             = StringHelper.AddSafe(RequestHelper.GetForm <string>("address"));
            order.ZipCode             = StringHelper.AddSafe(RequestHelper.GetForm <string>("zipcode"));
            order.Tel                 = StringHelper.AddSafe(RequestHelper.GetForm <string>("tel"));
            order.Email               = userEmail;
            order.Mobile              = StringHelper.AddSafe(RequestHelper.GetForm <string>("mobile"));
            order.ShippingId          = 0;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = 0;
            order.PayKey              = string.Empty;
            order.PayName             = string.Empty;
            order.PayDate             = RequestHelper.DateNow;;
            order.IsRefund            = (int)BoolType.False;
            order.FavorableActivityId = 0;
            order.GiftId              = 0;
            order.InvoiceTitle        = string.Empty;
            order.InvoiceContent      = string.Empty;
            order.UserMessage         = string.Empty;
            order.AddDate             = RequestHelper.DateNow;
            order.IP            = ClientHelper.IP;
            order.UserId        = base.UserId;
            order.UserName      = userName;
            order.ActivityPoint = Gift.Point * num;
            int orderID = OrderBLL.Add(order);

            //添加订单详细
            OrderDetailInfo orderDetail = new OrderDetailInfo();

            orderDetail.OrderId     = orderID;
            orderDetail.ProductId   = Gift.Id;
            orderDetail.ProductName = Gift.Name;
            //orderDetail.ProductWeight = Gift.Weight;
            orderDetail.SendPoint     = 0;
            orderDetail.ProductPrice  = 0;
            orderDetail.ActivityPoint = Gift.Point;
            orderDetail.BuyCount      = num;
            orderDetail.ParentId      = 0;
            orderDetail.RandNumber    = string.Empty;
            orderDetail.GiftPackId    = 0;
            OrderDetailBLL.Add(orderDetail);

            //积分记录
            var accountRecord = new UserAccountRecordInfo
            {
                Money    = 0,
                Point    = -Gift.Point * num,
                Date     = DateTime.Now,
                IP       = ClientHelper.IP,
                Note     = "兑换礼品-" + Gift.Name,
                UserId   = base.UserId,
                UserName = base.UserName
            };

            UserAccountRecordBLL.Add(accountRecord);

            //更新商品的已兑换数量
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("SendCount", Gift.SendCount + num);
            PointProductBLL.UpdatePart(PointProductInfo.TABLENAME, dict, Gift.Id);

            ResponseHelper.Write("ok|" + orderID);
            ResponseHelper.End();
        }
Пример #7
0
        private void SelectShipping()
        {
            int shippingId = RequestHelper.GetQueryString <int>("shippingId");
            //if (shippingId <= 0) {
            //    ResponseHelper.Write("error|请选择配送方式");
            //    ResponseHelper.End();
            //}
            string regionId  = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("regionId"));
            int    favorId   = RequestHelper.GetQueryString <int>("favorId");
            string checkCart = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart"));

            int[] cartIds = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
            if (string.IsNullOrEmpty(checkCart) || cartIds.Length < 1)
            {
                ResponseHelper.Write("error|请选择需要购买的商品");
                ResponseHelper.End();
            }

            //计算配送费用
            List <CartInfo> cartList = CartBLL.ReadList(base.UserId).Where(k => cartIds.Contains(k.Id)).ToList();

            if (cartList.Count < 1)
            {
                ResponseHelper.Write("error|请选择需要购买的商品");
                ResponseHelper.End();
            }

            int count = 0;
            //购物车结算金额
            decimal cartTotalPrice = 0;

            int[] ids         = cartList.Select(k => k.ProductId).ToArray();
            var   productList = ProductBLL.SearchList(1, ids.Length, new ProductSearchInfo {
                InProductId = string.Join(",", ids)
            }, ref count);

            cartList.ForEach(k => k.Product = productList.FirstOrDefault(k2 => k2.Id == k.ProductId) ?? new ProductInfo());
            foreach (var cart in cartList)
            {
                if (!string.IsNullOrEmpty(cart.StandardValueList))
                {
                    //使用规格的价格和库存
                    var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList);
                    cartTotalPrice += ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID) * cart.BuyCount;
                }
                else
                {
                    cartTotalPrice += ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID) * cart.BuyCount;
                }
            }

            //首先根据ShopId分组,根据供应商的不同来分别计算运费
            //然后将分拆后的供应商商品,按单个商品独立计算运费(相同商品购买多个则叠加计算)
            ShippingInfo       shipping       = ShippingBLL.Read(shippingId);
            ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shippingId, regionId);
            decimal            shippingMoney  = ShippingRegionBLL.ReadShippingMoney(shippingId, regionId, cartList);
            //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);
            //    }
            //}
            decimal favorableMoney = 0;

            #region 计算优惠费用
            if (favorId > 0)
            {
                var theFavorable = FavorableActivityBLL.Read(favorId);
                if (("," + theFavorable.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && cartTotalPrice >= theFavorable.OrderProductMoney)
                {
                    switch (theFavorable.ReduceWay)
                    {
                    case (int)FavorableMoney.Money:
                        favorableMoney += theFavorable.ReduceMoney;
                        break;

                    case (int)FavorableMoney.Discount:
                        favorableMoney += cartTotalPrice * (100 - theFavorable.ReduceDiscount) / 100;
                        break;

                    default:
                        break;
                    }
                    if (theFavorable.ShippingWay == (int)FavorableShipping.Free && ShippingRegionBLL.IsRegionIn(regionId, theFavorable.RegionId))
                    {
                        favorableMoney += shippingMoney;
                    }
                }
            }
            #endregion

            ResponseHelper.Write("ok|" + Math.Round(shippingMoney, 2).ToString() + "|" + Math.Round(favorableMoney, 2));
            ResponseHelper.End();
        }
Пример #8
0
        /// <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");

            //检查用户名
            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 (errorMessage == string.Empty)
            {
                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.Email         = email;
                user.RegisterIP    = ClientHelper.IP;
                user.RegisterDate  = RequestHelper.DateNow;
                user.LastLoginIP   = ClientHelper.IP;
                user.LastLoginDate = RequestHelper.DateNow;
                user.FindDate      = RequestHelper.DateNow;
                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("/User/Index.html");
                }
                else if (ShopConfig.ReadConfigInfo().RegisterCheck == 2)
                {
                    //邮件验证
                    string              url             = "http://" + Request.ServerVariables["HTTP_HOST"] + "/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>";
                }
                else
                {
                    //人工审核
                    result = "恭喜您,注册成功,请等待我们的审核!";
                }
                ResponseHelper.Redirect("/User/Register.html?Result=" + Server.UrlEncode(result));
            }
            else
            {
                ResponseHelper.Redirect("/User/Register.html?ErrorMessage=" + Server.UrlEncode(errorMessage));
            }
        }
Пример #9
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected void Post()
        {
            string   userName   = StringHelper.SearchSafe(RequestHelper.GetForm <string>("UserName"));
            string   email      = StringHelper.SearchSafe(RequestHelper.GetForm <string>("Email"));
            string   safeCode   = RequestHelper.GetForm <string>("SafeCode");
            int      checkType  = RequestHelper.GetForm <int>("checkType");
            string   mobile     = RequestHelper.GetForm <string>("Mobile");
            string   mobileCode = 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"] + "/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|/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"] + "/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;
            }
        }
Пример #10
0
        protected override void PostBack()
        {
            user = UserBLL.ReadUser(userID);

            int oldCompanyID   = user.CompanyID;
            int oldStudyPostID = user.StudyPostID;

            user.CompanyID = RequestHelper.GetForm <int>("CompanyID");
            if (user.CompanyID < 0)
            {
                user.CompanyID = oldCompanyID == int.MinValue ? base.UserCompanyID : oldCompanyID;
            }

            user.Department = RequestHelper.GetForm <int>("Department");
            if (user.Department < 0)
            {
                ScriptHelper.Alert("请选择部门");
            }

            user.WorkingPostID = RequestHelper.GetForm <int>("WorkingPostID");
            if (user.WorkingPostID < 0)
            {
                ScriptHelper.Alert("请选择岗位");
            }

            user.PostName = StringHelper.AddSafe(RequestHelper.GetForm <string>("WorkingPostName"));
            if (user.WorkingPostID < 0 && string.IsNullOrEmpty(user.PostName))
            {
                ScriptHelper.Alert("请填写店内岗位名称");
            }

            user.StudyPostID = RequestHelper.GetForm <int>("StudyPostID");
            if (user.StudyPostID < 0)
            {
                ScriptHelper.Alert("请选择学习岗位");
            }

            user.Email  = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
            user.Sex    = RequestHelper.GetForm <int>("Sex");
            user.QQ     = StringHelper.AddSafe(RequestHelper.GetForm <string>("QQ"));
            user.Status = RequestHelper.GetForm <int>("Status");
            if (user.Status < 0)
            {
                ScriptHelper.Alert("请选择状态");
            }

            //新增会员或有更改姓名的权限
            if (userID <= 0 || base.CompareUserPower("UpdateRealName", PowerCheckType.Single))
            {
                user.RealName = StringHelper.AddSafe(RequestHelper.GetForm <string>("RealName"));
            }

            //新增会员或有更改手机号码的权限
            if (userID <= 0 || base.CompareUserPower("UpdateMobile", PowerCheckType.Single))
            {
                user.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));
                if (string.IsNullOrEmpty(user.Mobile))
                {
                    ScriptHelper.Alert("请正确填写手机号码!");
                }
            }

            //验证手机号码是否存在
            //if (UserBLL.IsExistMobile(user.Mobile, user.ID))
            //    ScriptHelper.Alert("手机号码已存在");

            if (base.CompareUserPower("ShowIDCard", PowerCheckType.Single))
            {
                user.IDCard = StringHelper.AddSafe(RequestHelper.GetForm <string>("IDCard"));
            }

            if (base.CompareUserPower("ShowIDCard", PowerCheckType.Single) && !string.IsNullOrEmpty(RequestHelper.GetForm <string>("EntryDate")))
            {
                user.EntryDate = RequestHelper.GetForm <DateTime>("EntryDate");
            }

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (userID < 0)
            {
                base.CheckUserPower("AddUser", PowerCheckType.Single);
                user.Status = (int)UserState.Normal;

                if (UserBLL.IsUserNumOverflow(user.CompanyID))
                {
                    ScriptHelper.Alert("超过用户数量,暂不能添加!");
                }

                user.UserName = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName"));
                Regex regex = new Regex("^([a-zA-Z0-9_一-龥])+$");
                if (!regex.IsMatch(user.UserName))
                {
                    ScriptHelper.Alert("用户名只能包含字母、数字、下划线、中文");
                }

                if (UserBLL.CheckUserName(user.UserName) > 0)
                {
                    ScriptHelper.Alert("用户名已存在,请更换用户名!");
                }

                string userPassword  = RequestHelper.GetForm <string>("UserPassword");
                string userPassword2 = RequestHelper.GetForm <string>("UserPassword2");
                if (string.IsNullOrEmpty(userPassword) || string.IsNullOrEmpty(userPassword2) || userPassword != userPassword2)
                {
                    ScriptHelper.Alert("两次密码不一致");
                }
                regex = new Regex("(?=^[0-9a-zA-Z._@#]{6,16}$)((?=.*[0-9])(?=.*[^0-9])|(?=.*[a-zA-Z])(?=.*[^a-zA-Z]))");
                if (!regex.IsMatch(userPassword))
                {
                    ScriptHelper.Alert("密码为6-16位数字与字母的组合!");
                }
                user.UserPassword = StringHelper.Password(userPassword, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);

                user.GroupID = RequestHelper.GetForm <int>("GroupID");
                if (user.GroupID < 0)
                {
                    user.GroupID = 36;
                }

                int id = UserBLL.AddUser(user);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("User"), id);
            }
            else
            {
                base.CheckUserPower("UpdateUser", PowerCheckType.Single);

                //变换学习岗位,如果岗位已通过则更新注册时间,以便岗位计划按新时间重新计数,否则不更改原有岗位计划统计时间
                PostInfo studyPost    = PostBLL.ReadPost(user.StudyPostID);
                PostInfo oldStudyPost = PostBLL.ReadPost(oldStudyPostID);
                if (oldCompanyID != user.CompanyID || (user.StudyPostID != oldStudyPostID && (studyPost.ParentId == 3 || oldStudyPost.ParentId == 3) && studyPost.ParentId != oldStudyPost.ParentId))
                {
                    user.PostStartDate = DateTime.Today;
                }

                UserBLL.UpdateUser(user);

                //如果公司ID更改,相应修改成绩列表
                if (oldCompanyID != user.CompanyID)
                {
                    TestPaperBLL.UpdatePaperCompanyId(user.ID, user.CompanyID);
                }

                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("User"), user.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            string returnURL = ServerHelper.UrlDecode(RequestHelper.GetQueryString <string>("ReturnURL"));

            if (string.IsNullOrEmpty(returnURL))
            {
                ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl);
            }
            else
            {
                ScriptHelper.Alert(alertMessage, returnURL);
            }
        }
Пример #11
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            redirectUrl = HttpUtility.UrlDecode(RequestHelper.GetForm <string>("RedirectUrl"));
            if (redirectUrl == string.Empty)
            {
                redirectUrl = RequestHelper.GetQueryString <string>("RedirectUrl");
            }
            string   userName     = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName"));
            string   userPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string   autoLogin    = StringHelper.SearchSafe(RequestHelper.GetForm <string>("autoLogin"));
            UserInfo user         = UserBLL.Read(userName, userPassword);

            if (user.Id > 0)
            {
                switch (user.Status)
                {
                case (int)UserStatus.NoCheck:
                    result = "该用户未激活";
                    break;

                case (int)UserStatus.Frozen:
                    result = "该用户已冻结";
                    break;

                case (int)UserStatus.Normal:
                    user = UserBLL.ReadUserMore(user.Id);
                    UserBLL.UserLoginInit(user);
                    //如果设置了自动登录则保存COOKIES一周
                    if (string.Equals(autoLogin, "1"))
                    {
                        UserBLL.AddUserCookieWeekly(user);
                    }
                    //否则不保存(关闭浏览器即失效)
                    else
                    {
                        UserBLL.AddUserCookie(user);
                    }

                    if (redirectUrl != string.Empty)
                    {
                        ResponseHelper.Redirect(redirectUrl);
                    }
                    else
                    {
                        ResponseHelper.Redirect("/User/Index.html");
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                result = "用户名或者密码错误";
            }
            string url = "/User/Login.html?Message=" + result;

            if (redirectUrl != string.Empty)
            {
                url += "&RedirectUrl=" + redirectUrl;
            }
            ResponseHelper.Redirect(url);
        }