Beispiel #1
0
 protected override void PageLoad()
 {
     base.PageLoad();
     if ((ShopConfig.ReadConfigInfo().AllowAnonymousAddCart == 0) && (base.UserID == 0))
     {
         ResponseHelper.Redirect("/User/Login.aspx?RedirectUrl=/CheckOut.aspx");
         ResponseHelper.End();
     }
     if ((Sessions.ProductBuyCount == 0) || (Sessions.ProductTotalPrice == 0M))
     {
         ResponseHelper.Redirect("/Cart.aspx");
         ResponseHelper.End();
     }
     if (base.UserID > 0)
     {
         this.userAddressList = UserAddressBLL.ReadUserAddressByUser(base.UserID);
         List <UserCouponInfo> list = UserCouponBLL.ReadUserCouponCanUse(base.UserID);
         foreach (UserCouponInfo info in list)
         {
             if (info.Coupon.UseMinAmount <= Sessions.ProductTotalPrice)
             {
                 this.userCouponList.Add(info);
             }
         }
         this.moneyLeft = UserBLL.ReadUserMore(base.UserID).MoneyLeft;
     }
     this.payPluginsList    = PayPlugins.ReadProductBuyPayPluginsList();
     this.favorableActivity = FavorableActivityBLL.ReadFavorableActivity(DateTime.Now, DateTime.Now, 0);
     if (this.favorableActivity.ID > 0)
     {
         if ((("," + this.favorableActivity.UserGrade + ",").IndexOf("," + this.GradeID.ToString() + ",") > -1) && (Sessions.ProductTotalPrice >= this.favorableActivity.OrderProductMoney))
         {
             if (this.favorableActivity.GiftID != string.Empty)
             {
                 GiftSearchInfo gift = new GiftSearchInfo();
                 gift.InGiftID = this.favorableActivity.GiftID;
                 this.giftList = GiftBLL.SearchGiftList(gift);
             }
         }
         else
         {
             this.favorableActivity = new FavorableActivityInfo();
         }
     }
     base.Title = "结算中心";
 }
Beispiel #2
0
        protected override void PageLoad()
        {
            base.PageLoad();

            //登录验证
            if (base.UserId <= 0)
            {
                string redirectUrl = "/Mobile/login.html?RedirectUrl=/mobile/CheckOut.html";

                ResponseHelper.Redirect(redirectUrl);
                ResponseHelper.End();
            }

            //购物车验证
            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.Redirect("/Mobile/cart.html");
                ResponseHelper.End();
            }


            //cart list
            #region cart list
            //商品清单
            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 (cart.Product.StandardType == 1)
                {
                    //使用规格的价格和库存
                    var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList);
                    cart.Price            = standardRecord.SalePrice;
                    cart.LeftStorageCount = standardRecord.Storage - OrderDetailBLL.GetOrderCount(cart.ProductId, cart.StandardValueList);
                    //规格集合
                    cart.Standards = ProductTypeStandardBLL.ReadList(Array.ConvertAll <string, int>(standardRecord.StandardIdList.Split(';'), k => Convert.ToInt32(k)));
                }
                else
                {
                    cart.Price            = cart.Product.SalePrice;
                    cart.LeftStorageCount = cart.Product.TotalStorageCount - OrderDetailBLL.GetOrderCount(cart.ProductId, cart.StandardValueList);
                }

                if (cart.LeftStorageCount <= 0)
                {
                    ScriptHelper.AlertFront("您购物车中 " + cart.Product.Name + " 库存不足,请重新选择", "/Mobile/Cart.html");
                }
            }
            #endregion

            //收货地址
            addressList = UserAddressBLL.ReadList(base.UserId);
            addressList = addressList.OrderByDescending(k => k.IsDefault).ToList();
            singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass();

            totalProductMoney = cartList.Sum(k => k.BuyCount * k.Price);
            //用户信息
            var user = UserBLL.Read(base.UserId);
            if (user.Id > 0)
            {
                //读取优惠券
                List <UserCouponInfo> tempUserCouponList = UserCouponBLL.ReadCanUse(base.UserId);
                foreach (UserCouponInfo userCoupon in tempUserCouponList)
                {
                    CouponInfo tempCoupon = CouponBLL.Read(userCoupon.CouponId);
                    if (tempCoupon.UseMinAmount <= totalProductMoney)
                    {
                        userCouponList.Add(userCoupon);
                    }
                }

                moneyLeft = UserBLL.ReadUserMore(base.UserId).MoneyLeft;
            }
            //读取优惠活动
            favorableActivity = FavorableActivityBLL.Read(DateTime.Now, DateTime.Now, 0);
            if (favorableActivity.Id > 0)
            {
                if (("," + favorableActivity.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && Sessions.ProductTotalPrice >= favorableActivity.OrderProductMoney)
                {
                    if (favorableActivity.GiftId != string.Empty)
                    {
                        FavorableActivityGiftSearchInfo giftSearch = new FavorableActivityGiftSearchInfo();
                        giftSearch.InGiftIds = Array.ConvertAll <string, int>(favorableActivity.GiftId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
                        giftList             = FavorableActivityGiftBLL.SearchList(giftSearch);
                    }
                }
                else
                {
                    favorableActivity = new FavorableActivityInfo();
                }
            }
            //支付方式列表
            payPluginsList = PayPlugins.ReadProductBuyPayPluginsList();

            Title = "结算中心";
        }
Beispiel #3
0
        protected override void PageLoad()
        {
            base.PageLoad();

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

            switch (action)
            {
            case "Submit":
                this.Submit();
                break;
            }

            //登录验证
            if (base.UserId <= 0)
            {
                string redirectUrl = string.IsNullOrEmpty(isMobile)
                    ? "/user/login.html?RedirectUrl=/checkout.html"
                    : isMobile + "/login.aspx?RedirectUrl=/mobile/CheckOut.aspx";

                ResponseHelper.Redirect(redirectUrl);
                ResponseHelper.End();
            }

            //购物车验证
            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.Redirect("/cart.html");
                ResponseHelper.End();
            }

            //用户信息
            var user = UserBLL.Read(base.UserId);

            //cart list
            #region cart list
            //商品清单
            cartList = CartBLL.ReadList(base.UserId);
            cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList();
            if (cartList.Count < 1)
            {
                ResponseHelper.Redirect("/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);
                    cart.Price            = standardRecord.SalePrice;
                    cart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount;
                    //规格集合
                    cart.Standards = ProductTypeStandardBLL.ReadList(Array.ConvertAll <string, int>(standardRecord.StandardIdList.Split(';'), k => Convert.ToInt32(k)));
                }
                else
                {
                    cart.Price            = cart.Product.SalePrice;
                    cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount;
                }
            }
            #endregion

            //收货地址
            addressList = UserAddressBLL.ReadList(base.UserId);
            addressList = addressList.OrderByDescending(k => k.IsDefault).ToList();
            singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass();

            var totalProductMoney = cartList.Sum(k => k.BuyCount * k.Price);
            //取得图楼卡余额的webservice
            if (!string.IsNullOrEmpty(user.CardNo) && !string.IsNullOrEmpty(user.CardPwd))
            {
                bool isSuccess; string msg;
                isSuccess = true;
                msg       = "";
                //var account = WebService.Account.GetAccount(user.CardNo, user.CardPwd, out isSuccess, out msg);
                moneyLeft = 0;// account.Zacc + account.Sacc;
                if (moneyLeft > 0)
                {
                    moneyCanUse = moneyLeft > totalProductMoney ? totalProductMoney : moneyLeft;
                }
            }

            /*----------------不可使用积分-------------------------------------------------------------------------
            *  decimal totalRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointTotalRate;
            *  decimal pointRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointMoneyRate;
            *  if (totalRate > 0 && pointRate > 0 && pointLeft > 0)
            *  {
            *   var pointPayMoney = Math.Round(totalProductMoney * totalRate, 2, MidpointRounding.AwayFromZero);
            *   pointCanUse = pointPayMoney * pointRate;
            *   if (pointCanUse > pointLeft)
            *   {
            *       pointCanUse = pointLeft;
            *   }
            *  }
            *  ----------------不可使用积分-------------------------------------------------------------------------*/

            //支付方式列表
            payPluginsList = PayPlugins.ReadProductBuyPayPluginsList();

            Title = "结算中心";
        }
Beispiel #4
0
        protected override void PageLoad()
        {
            base.PageLoad();
            istop = 1;
            string action = RequestHelper.GetQueryString <string>("Action");

            switch (action)
            {
            case "Submit":
                this.Submit();
                break;

            case "SelectProductFavor":   //读取商品优惠
                this.SelectProductFavor();
                break;

            case "ReadingGifts":    //读取礼品列表
                this.ReadingGifts();
                break;
            }

            //登录验证
            if (base.UserId <= 0)
            {
                ResponseHelper.Redirect("/user/login.html?RedirectUrl=/checkout.html");
                ResponseHelper.End();
            }
            if (base._UserType == (int)UserType.Provider)
            {
                ResponseHelper.Redirect("/");
                ResponseHelper.End();
            }

            //购物车验证
            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.Redirect("/cart.html");
                ResponseHelper.End();
            }

            //用户信息
            var user = UserBLL.ReadUserMore(base.UserId);

            //剩余积分
            pointLeft = user.PointLeft;
            //cart list
            #region cart list
            //商品清单
            cartList = CartBLL.ReadList(base.UserId);
            cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList();
            if (cartList.Count < 1)
            {
                ResponseHelper.Redirect("/cart.html");
                ResponseHelper.End();
            }

            //关联的商品
            int   count       = 0;
            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;
                    cart.Price            = ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID);
                    //规格集合
                    if (!string.IsNullOrEmpty(standardRecord.StandardIdList))
                    {
                        cart.Standards = ProductTypeStandardBLL.ReadList(Array.ConvertAll <string, int>(standardRecord.StandardIdList.Split(';'), k => Convert.ToInt32(k)));
                    }
                }
                else
                {
                    cart.Price            = ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID);
                    cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount;
                }


                //检查库存
                if (cart.BuyCount > cart.LeftStorageCount)
                {
                    ScriptHelper.AlertFront("商品[" + cart.ProductName + "]库存不足,无法购买");
                    ResponseHelper.End();
                }
            }

            #endregion

            //收货地址
            addressList = UserAddressBLL.ReadList(base.UserId);
            addressList = addressList.OrderByDescending(k => k.IsDefault).ToList();
            singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass();

            var totalProductMoney = cartList.Sum(k => k.BuyCount * k.Price);

            //支付方式列表
            payPluginsList = PayPlugins.ReadProductBuyPayPluginsList();
            #region 优惠券
            if (user.Id > 0)
            {
                //读取优惠券
                List <UserCouponInfo> tempUserCouponList = UserCouponBLL.ReadCanUse(base.UserId);
                foreach (UserCouponInfo userCoupon in tempUserCouponList)
                {
                    CouponInfo tempCoupon = CouponBLL.Read(userCoupon.CouponId);
                    if (tempCoupon.UseMinAmount <= totalProductMoney)
                    {
                        userCouponList.Add(userCoupon);
                    }
                }
            }
            #endregion
            #region 获取符合条件(时间段,用户等级,金额限制)的商品分类优惠活动列表,默认使用第一个

            var tmpfavorableActivityList = FavorableActivityBLL.ReadList(DateTime.Now, DateTime.Now).Where <FavorableActivityInfo>(f => f.Type == (int)FavorableType.ProductClass && ("," + f.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1).ToList();
            foreach (var favorable in tmpfavorableActivityList)
            {
                decimal tmoney = 0;
                //tmoney = cartList.Where(c => c.Product.ClassId.IndexOf(favorable.ClassIds) > -1).Sum(k => k.BuyCount * k.Price);
                foreach (var tmpcart in cartList)
                {
                    if (tmpcart.Product.ClassId.IndexOf(favorable.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;
                        }
                    }
                }
                if (tmoney >= favorable.OrderProductMoney)
                {
                    productFavorableActivityList.Add(favorable);
                }
            }
            #endregion
            Title = "结算中心";
        }
Beispiel #5
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();
            int groupID = RequestHelper.GetQueryString <int>("ID");

            buyCount = RequestHelper.GetQueryString <int>("BuyCount");

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

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

            //登录验证
            if (ShopConfig.ReadConfigInfo().AllowAnonymousAddCart == (int)BoolType.False && base.UserID == 0)
            {
                ResponseHelper.Redirect("/User/Login.aspx?RedirectUrl=/GroupBuyOrder-" + groupID + "-" + buyCount + ".aspx");
                ResponseHelper.End();
            }
            //读取数据
            if (base.UserID > 0)
            {
                userAddressList = UserAddressBLL.ReadUserAddressByUser(base.UserID);
            }
            payPluginsList = PayPlugins.ReadProductBuyPayPluginsList();
            Title          = "团购订单";
        }