示例#1
0
        protected override void PageLoad()
        {
            base.PageLoad();

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

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

            int id      = RequestHelper.GetQueryString <int>("id");
            var address = UserAddressBLL.Read(id, base.UserId);

            if (string.IsNullOrEmpty(address.RegionId))
            {
                return;
            }

            //取出所有配送方式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());

            //查找符合条件的配送方式
            foreach (ShippingInfo shipping in tempShippingList)
            {
                string tempRegionId = address.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);
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ClearCache();
            orderShippingId = RequestHelper.GetQueryString <int>("ShippingID");;
            string regionId = RequestHelper.GetQueryString <string>("RegionID");

            if (!string.IsNullOrEmpty(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());

                //查找符合条件的配送方式
                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);
                        }
                    }
                }
            }
        }
示例#3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         CheckAdminPower("ReadShipping", PowerCheckType.Single);
         string action     = RequestHelper.GetQueryString <string>("Action");
         int    shippingId = RequestHelper.GetQueryString <int>("Id");
         if (shippingId != 0 && action != string.Empty)
         {
             CheckAdminPower("UpdateShipping", PowerCheckType.Single);
             ChangeAction changeAction = ChangeAction.Up;
             if (action == "Down")
             {
                 changeAction = ChangeAction.Down;
             }
             ShippingBLL.Move(changeAction, shippingId);
             AdminLogBLL.Add(ShopLanguage.ReadLanguage("MoveRecord"), ShopLanguage.ReadLanguage("Shipping"), shippingId);
         }
         BindControl(ShippingBLL.ReadList(), RecordList);
     }
 }
        private void SelectShipping()
        {
            int productId = RequestHelper.GetQueryString <int>("productId");

            if (productId < 1)
            {
                ResponseHelper.Write("-1");
                ResponseHelper.End();
            }

            SingleUnlimitClass singleUnlimitClass2 = new SingleUnlimitClass();
            string             regionId            = singleUnlimitClass2.ClassID;

            //当前产品
            var product = ProductBLL.Read(productId);
            //所有可用的配送方式
            var shippingList = ShippingBLL.ReadList().Where(k => k.IsEnabled == (int)BoolType.True).ToList();

            //无可用的配送方式,返回-10
            if (shippingList.Count < 1)
            {
                ResponseHelper.Write("-10");
                ResponseHelper.End();
            }

            var shippingIds = new List <int>();

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

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

            //该区域没有物流配送,返回-11
            if (shippingRegionList.Count < 1)
            {
                ResponseHelper.Write("-11");
                ResponseHelper.End();
            }

            //比较匹配出来的配送数据,取最高价(只计算单件商品的价格)
            List <decimal> listShippingMoney = new List <decimal>();

            foreach (ShippingInfo shipping in shippingList)
            {
                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;

                            decimal shippingMoney = 0;
                            switch (shipping.ShippingType)
                            {
                            case (int)ShippingType.Fixed:
                                shippingMoney = temp.FixedMoeny;
                                listShippingMoney.Add(shippingMoney);
                                break;

                            case (int)ShippingType.Weight:
                                if (product.Weight <= shipping.FirstWeight)
                                {
                                    shippingMoney = temp.FirstMoney;
                                }
                                else
                                {
                                    shippingMoney = temp.FirstMoney + Math.Ceiling((product.Weight - shipping.FirstWeight) / shipping.AgainWeight) * temp.AgainMoney;
                                }
                                listShippingMoney.Add(shippingMoney);
                                break;

                            case (int)ShippingType.ProductCount:
                                int productCount = 1;
                                shippingMoney = temp.OneMoeny + (productCount - 1) * temp.AnotherMoeny;
                                listShippingMoney.Add(shippingMoney);
                                break;

                            default:
                                break;
                            }
                            break;
                        }
                    }
                    if (isFind)
                    {
                        break;
                    }
                    else
                    {
                        tempRegionId = tempRegionId.Substring(0, tempRegionId.Length - 1);
                        tempRegionId = tempRegionId.Substring(0, tempRegionId.LastIndexOf('|') + 1);
                    }
                }
            }

            CookiesHelper.AddCookie("usr_region", regionId, 1, TimeType.Year);
            //该区域没有物流配送,返回-11
            if (listShippingMoney.Count < 1)
            {
                ResponseHelper.Write("-11");
                ResponseHelper.End();
            }
            else
            {
                ResponseHelper.Write(listShippingMoney.Max().ToString());
                ResponseHelper.End();
            }
        }
        protected override void PageLoad()
        {
            base.PageLoad();

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

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

            int id = RequestHelper.GetQueryString <int>("id");

            address = UserAddressBLL.Read(id, base.UserId);

            if (string.IsNullOrEmpty(address.RegionId))
            {
                return;
            }

            //取出所有配送方式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 = address.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);
                    }
                }
            }
        }