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

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

            if (orderid > 0)
            {
                tempOrder = OrderBLL.Read(orderid);
                ShippingInfo tempShipping = ShippingBLL.Read(tempOrder.ShippingId);

                string show = RequestHelper.GetQueryString <string>("show");

                //string apiurl = "http://api.kuaidi100.com/api?id=2815b2d431fdfd26&com=" + typeCom + "&nu=" + nu + "&show=" + show + "&muti=1&order=asc";
                string apiurl = "https://m.kuaidi100.com/index_all.html?type=" + tempShipping.ShippingCode + "&postid=" + tempOrder.ShippingNumber + "&callbackurl=" + "http://" + HttpContext.Current.Request.Url.Host + "/mobile/User/OrderDetail.html?ID=" + orderid;
                ////Response.Write (apiurl);
                //WebRequest request = WebRequest.Create(@apiurl);
                //WebResponse response = request.GetResponse();
                //Stream stream = response.GetResponseStream();
                //Encoding encode = Encoding.UTF8;
                //StreamReader reader = new StreamReader(stream, encode);

                //shippingStr = reader.ReadToEnd();
                // Response.Redirect(apiurl);
                Response.Write("<script>window.location.href='" + apiurl + "'</script>");
                Response.End();
            }
        }
示例#2
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            ShippingInfo shipping = new ShippingInfo();

            shipping.ID           = RequestHelper.GetQueryString <int>("ID");
            shipping.Name         = this.Name.Text;
            shipping.Description  = this.Description.Text;
            shipping.IsEnabled    = Convert.ToInt32(this.IsEnabled.Text);
            shipping.ShippingType = Convert.ToInt32(this.ShippingType.Text);
            shipping.FirstWeight  = Convert.ToInt32(this.FirstWeight.Text);
            shipping.AgainWeight  = Convert.ToInt32(this.AgainWeight.Text);
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (shipping.ID == -2147483648)
            {
                base.CheckAdminPower("AddShipping", PowerCheckType.Single);
                int id = ShippingBLL.AddShipping(shipping);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Shipping"), id);
            }
            else
            {
                base.CheckAdminPower("UpdateShipping", PowerCheckType.Single);
                ShippingBLL.UpdateShipping(shipping);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Shipping"), shipping.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
示例#3
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);
                    }
                }
            }
        }
示例#4
0
        private void SelectShipping()
        {
            int shippingId = RequestHelper.GetQueryString <int>("shippingId");
            int addressId  = RequestHelper.GetQueryString <int>("addressId");

            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();
            }

            var address = UserAddressBLL.Read(addressId, base.UserId);

            //计算配送费用
            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;

            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());

            decimal shippingMoney = 0;
            //首先根据ShopId分组,根据供应商的不同来分别计算运费
            //然后将分拆后的供应商商品,按单个商品独立计算运费(相同商品购买多个则叠加计算)
            ShippingInfo       shipping       = ShippingBLL.Read(shippingId);
            ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shippingId, address.RegionId);

            var shopIds = cartList.GroupBy(k => k.Product.ShopId).Select(k => k.Key).ToList();

            foreach (var shopId in shopIds)
            {
                var shopCartList = cartList.Where(k => k.Product.ShopId == shopId).ToList();
                foreach (var shopCartSplit in shopCartList)
                {
                    shippingMoney += ShippingRegionBLL.ReadShippingMoney(shipping, shippingRegion, shopCartSplit);
                }
            }

            //decimal shippingMoney = ShippingRegionBLL.ReadShippingMoney(shippingId, address.RegionId, cartList);
            ResponseHelper.Write("ok|" + Math.Round(shippingMoney, 2).ToString());
            ResponseHelper.End();
        }
示例#5
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            base.CheckAdminPower("DeleteShipping", PowerCheckType.Single);
            string intsForm = RequestHelper.GetIntsForm("SelectID");

            if (intsForm != string.Empty)
            {
                ShippingBLL.DeleteShipping(intsForm);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("Shipping"), intsForm);
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("DeleteOK"), RequestHelper.RawUrl);
            }
        }
示例#6
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();
            string regionID = RequestHelper.GetQueryString <string>("RegionID");

            if (regionID != string.Empty)
            {
                //取出所有配送方式ID
                List <ShippingInfo> tempShippingList = ShippingBLL.ReadShippingIsEnabledCacheList();
                string strShippingID = string.Empty;
                foreach (ShippingInfo shipping in tempShippingList)
                {
                    if (strShippingID == string.Empty)
                    {
                        strShippingID = shipping.Id.ToString();
                    }
                    else
                    {
                        strShippingID += "," + shipping.Id.ToString();
                    }
                }
                //读取配送区域列表
                List <ShippingRegionInfo> shippingRegionList = ShippingRegionBLL.ReadList(Array.ConvertAll <string, int>(strShippingID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)));
                //查找符合条件的配送方式
                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);
                        }
                    }
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
示例#8
0
        protected override void PageLoad()
        {
            base.PageLoad();
            string queryString = RequestHelper.GetQueryString <string>("RegionID");

            if (queryString != string.Empty)
            {
                List <ShippingInfo> list = ShippingBLL.ReadShippingIsEnabledCacheList();
                string strShippingID     = string.Empty;
                foreach (ShippingInfo info in list)
                {
                    if (strShippingID == string.Empty)
                    {
                        strShippingID = info.ID.ToString();
                    }
                    else
                    {
                        strShippingID = strShippingID + "," + info.ID.ToString();
                    }
                }
                List <ShippingRegionInfo> list2 = ShippingRegionBLL.ReadShippingRegionByShipping(strShippingID);
                foreach (ShippingInfo info in list)
                {
                    for (string str3 = queryString; str3.Length >= 1; str3 = str3.Substring(0, str3.LastIndexOf('|') + 1))
                    {
                        bool flag = false;
                        foreach (ShippingRegionInfo info2 in list2)
                        {
                            if ((("|" + info2.RegionID + "|").IndexOf("|" + str3 + "|") > -1) && (info2.ShippingID == info.ID))
                            {
                                flag = true;
                                this.shippingList.Add(info);
                                break;
                            }
                        }
                        if (flag)
                        {
                            break;
                        }
                        str3 = str3.Substring(0, str3.Length - 1);
                    }
                }
            }
        }
示例#9
0
        /// <summary>
        /// 读取单元格的值
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        private Dictionary <int[], string> ReadCellParameters(OrderInfo order)
        {
            Dictionary <int[], string> cellDic = new Dictionary <int[], string>();

            cellDic.Add(new int[] { 1, 1 }, order.OrderNumber);
            cellDic.Add(new int[] { 1, 3 }, order.UserName);
            cellDic.Add(new int[] { 1, 5 }, order.AddDate.ToString());
            cellDic.Add(new int[] { 2, 1 }, order.PayName);
            cellDic.Add(new int[] { 2, 3 }, ShippingBLL.Read(order.ShippingId).Name);
            cellDic.Add(new int[] { 2, 5 }, order.ShippingNumber);
            cellDic.Add(new int[] { 3, 1 }, order.Consignee);
            cellDic.Add(new int[] { 3, 3 }, order.ZipCode);
            cellDic.Add(new int[] { 3, 5 }, order.Tel + " " + order.Mobile);
            cellDic.Add(new int[] { 4, 1 }, "[" + RegionBLL.RegionNameList(order.RegionId) + "] " + order.Address);
            cellDic.Add(new int[] { 5, 1 }, order.UserMessage);
            cellDic.Add(new int[] { 21, 0 }, "产品金额:" + order.ProductMoney + " 元" + " + 运费:" + order.ShippingMoney + " 元 + 其它费用:" + order.OtherMoney + "元 - 优惠券:" + order.CouponMoney + "元 - 优惠活动" + order.FavorableMoney + "元 - 积分抵扣金额:" + order.PointMoney + " 元 - 余额:" + order.Balance + " 元");
            cellDic.Add(new int[] { 22, 0 }, "应付金额:" + OrderBLL.ReadNoPayMoney(order).ToString() + " 元");
            cellDic.Add(new int[] { 23, 0 }, "打印时间:" + RequestHelper.DateNow.ToString("yyyy-MM-dd") + "  操作者:" + Cookies.Admin.GetAdminName(false));
            return(cellDic);
        }
示例#10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         int queryString = RequestHelper.GetQueryString <int>("ID");
         if (queryString != -2147483648)
         {
             base.CheckAdminPower("ReadShipping", PowerCheckType.Single);
             ShippingInfo info = ShippingBLL.ReadShippingCache(queryString);
             this.Name.Text         = info.Name;
             this.Description.Text  = info.Description;
             this.IsEnabled.Text    = info.IsEnabled.ToString();
             this.ShippingType.Text = info.ShippingType.ToString();
             if (info.ShippingType == 2)
             {
                 this.FirstWeight.Text = info.FirstWeight.ToString();
                 this.AgainWeight.Text = info.AgainWeight.ToString();
             }
         }
     }
 }
示例#11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         base.CheckAdminPower("ReadShipping", PowerCheckType.Single);
         string queryString = RequestHelper.GetQueryString <string>("Action");
         int    id          = RequestHelper.GetQueryString <int>("ID");
         if ((id != 0) && (queryString != string.Empty))
         {
             base.CheckAdminPower("UpdateShipping", PowerCheckType.Single);
             ChangeAction up = ChangeAction.Up;
             if (queryString == "Down")
             {
                 up = ChangeAction.Down;
             }
             ShippingBLL.ChangeShippingOrder(up, id);
             AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("MoveRecord"), ShopLanguage.ReadLanguage("Shipping"), id);
         }
         base.BindControl(ShippingBLL.ReadShippingCacheList(), this.RecordList);
     }
 }
示例#12
0
        /// <summary>
        /// Html打印
        /// </summary>
        /// <param name="order"></param>
        /// <param name="orderDetailList"></param>
        private void HtmlPrint(OrderInfo order, List <OrderDetailInfo> orderDetailList)
        {
            using (StreamReader sr = new StreamReader(ServerHelper.MapPath("/Admin/Print/Template.htm")))
            {
                orderHtml = sr.ReadToEnd();
            }
            //特殊标签
            orderHtml = orderHtml.Replace("<$RegionID$>", RegionBLL.RegionNameList(order.RegionId));
            orderHtml = orderHtml.Replace("<$ShippingName$>", ShippingBLL.Read(order.ShippingId).Name);
            orderHtml = orderHtml.Replace("<$PrintTime$>", RequestHelper.DateNow.ToString("yyyy-MM-dd"));
            orderHtml = orderHtml.Replace("<$ActionUser$>", Cookies.Admin.GetAdminName(false));
            orderHtml = orderHtml.Replace("<$NoPayMoney$>", OrderBLL.ReadNoPayMoney(order).ToString());
            //订单字段
            Type type = typeof(OrderInfo);

            PropertyInfo[] propertyArray = type.GetProperties().Take(44).ToArray();
            foreach (PropertyInfo property in propertyArray)
            {
                orderHtml = orderHtml.Replace("<$" + property.Name + "$>", property.GetValue(order, null).ToString());
            }
            //订单详细
            string strOrderDetailList = string.Empty;
            int    i = 1;

            foreach (OrderDetailInfo orderDetail in orderDetailList)
            {
                strOrderDetailList += "<tr align=\"middle\">";
                strOrderDetailList += "<td>" + i.ToString() + "</td>";
                strOrderDetailList += "<td align=\"left\">" + orderDetail.ProductName + "</td>";
                strOrderDetailList += "<td>" + orderDetail.BuyCount + "</td>";
                strOrderDetailList += "<td>" + orderDetail.ProductPrice.ToString("n") + "</td>";
                strOrderDetailList += "<td>" + (orderDetail.BuyCount * orderDetail.ProductPrice).ToString("n") + "</td>";
                strOrderDetailList += "</tr>";
                i++;
            }
            orderHtml = orderHtml.Replace("<$OrderDetailList$>", strOrderDetailList);
        }
示例#13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         base.CheckAdminPower("ReadShippingRegion", PowerCheckType.Single);
         this.RegionID.DataSource = RegionBLL.ReadRegionUnlimitClass();
         this.shippingID          = RequestHelper.GetQueryString <int>("ShippingID");
         this.shipping            = ShippingBLL.ReadShippingCache(this.shippingID);
         int queryString = RequestHelper.GetQueryString <int>("ID");
         if (queryString != -2147483648)
         {
             ShippingRegionInfo info = new ShippingRegionInfo();
             info                      = ShippingRegionBLL.ReadShippingRegion(queryString);
             this.Name.Text            = info.Name;
             this.RegionID.ClassIDList = info.RegionID;
             this.FixedMoeny.Text      = info.FixedMoeny.ToString();
             this.FirstMoney.Text      = info.FirstMoney.ToString();
             this.AgainMoney.Text      = info.AgainMoney.ToString();
             this.OneMoeny.Text        = info.OneMoeny.ToString();
             this.AnotherMoeny.Text    = info.AnotherMoeny.ToString();
         }
         base.BindControl(ShippingRegionBLL.ReadShippingRegionByShipping(this.shippingID.ToString()), this.RecordList);
     }
 }
示例#14
0
        /// <summary>
        /// 导出
        /// </summary>
        private void ExportSingle()
        {
            int orderId         = RequestHelper.GetQueryString <int>("OrderId");
            var order           = OrderBLL.Read(orderId);
            var orderDetailList = OrderDetailBLL.ReadList(orderId);

            try
            {
                string templetFile = Server.MapPath("/Admin/Print/Template_ExportSingle.xls");
                string outFile     = "/Admin/Print/Order/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + Guid.NewGuid().ToString() + ".xls";
                string outFullFile = Server.MapPath(outFile);

                OrderExcelHelper orderExcel = new OrderExcelHelper(templetFile, outFullFile);

                /*---------组装订单详细 start-----------------------------------*/
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("Index", Type.GetType("System.Int32")));
                dt.Columns.Add(new DataColumn("ProductName", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("BuyCount", Type.GetType("System.Int32")));
                dt.Columns.Add(new DataColumn("ProductPrice", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("Weight", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("TotalProductPrice", Type.GetType("System.String")));
                int i = 0;
                foreach (OrderDetailInfo orderDetail in orderDetailList)
                {
                    i++;
                    DataRow row = dt.NewRow();
                    row["Index"]             = i;
                    row["ProductName"]       = orderDetail.ProductName;
                    row["BuyCount"]          = orderDetail.BuyCount;
                    row["ProductPrice"]      = (orderDetail.ProductPrice).ToString("n");
                    row["Weight"]            = (orderDetail.ProductWeight).ToString("n");
                    row["TotalProductPrice"] = (orderDetail.BuyCount * orderDetail.ProductPrice).ToString("n");
                    dt.Rows.Add(row);
                }

                orderExcel.Dt = dt;
                /*---------组装订单详细 end-------------------------------------*/

                /*---------设置单元格值 start-----------------------------------*/
                Dictionary <int[], string> cellDic = new Dictionary <int[], string>();

                //基本信息
                cellDic.Add(new int[] { 2, 1 }, order.OrderNumber);
                cellDic.Add(new int[] { 2, 3 }, OrderBLL.ReadOrderStatus(order.OrderStatus, order.IsDelete));
                cellDic.Add(new int[] { 2, 5 }, order.PayName);
                cellDic.Add(new int[] { 2, 7 }, order.UserName);
                cellDic.Add(new int[] { 3, 1 }, order.AddDate.ToString());
                cellDic.Add(new int[] { 3, 3 }, order.PayDate.ToString());

                //邮寄信息
                cellDic.Add(new int[] { 5, 1 }, order.Consignee);
                cellDic.Add(new int[] { 5, 3 }, RegionBLL.RegionNameList(order.RegionId));
                cellDic.Add(new int[] { 5, 5 }, order.ZipCode);
                cellDic.Add(new int[] { 6, 1 }, order.Address);
                cellDic.Add(new int[] { 7, 1 }, order.Tel);
                cellDic.Add(new int[] { 7, 3 }, order.Email);
                cellDic.Add(new int[] { 7, 5 }, order.Mobile);
                cellDic.Add(new int[] { 8, 1 }, ShippingBLL.Read(order.ShippingId).Name);
                cellDic.Add(new int[] { 8, 3 }, order.ShippingDate.ToString("yyyy-MM-dd"));
                cellDic.Add(new int[] { 8, 5 }, order.ShippingNumber);

                //其他信息
                cellDic.Add(new int[] { 10, 1 }, order.UserMessage);
                cellDic.Add(new int[] { 11, 1 }, order.OrderNote);

                //汇总信息
                cellDic.Add(new int[] { 28, 0 }, "产品金额:" + order.ProductMoney + " 元" + " + 运费:" + order.ShippingMoney + " 元 + 其它费用:" + order.OtherMoney + "元 - 积分抵扣金额:" + order.PointMoney + " 元 - 余额:" + order.Balance + " 元");
                cellDic.Add(new int[] { 29, 0 }, "应付金额:" + OrderBLL.ReadNoPayMoney(order).ToString() + " 元");
                cellDic.Add(new int[] { 30, 0 }, "打印时间:" + RequestHelper.DateNow.ToString("yyyy-MM-dd") + "  操作者:" + Cookies.Admin.GetAdminName(false));

                orderExcel.CellParameters = cellDic;
                /*---------设置单元格值 end-------------------------------------*/
                orderExcel.Rows            = 14;
                orderExcel.Left            = 0;
                orderExcel.Top             = 14;
                orderExcel.SheetPrefixName = order.OrderNumber;
                orderExcel.DataTableToExcel();

                string excelPath = "http://" + HttpContext.Current.Request.ServerVariables["Http_Host"] + outFile.Replace("\\", "/");
                ResponseHelper.Redirect(excelPath);
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex, true);
            }
        }
示例#15
0
        /// <summary>
        /// 选择配送方式
        /// </summary>
        protected void SelectShipping()
        {
            int    shippingID = RequestHelper.GetQueryString <int>("ShippingID");
            string regionID   = RequestHelper.GetQueryString <string>("RegionID");
            //计算配送费用
            decimal            shippingMoney  = 0;
            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;
            }
            //计算优惠费用
            decimal favorableMoney = 0;
            FavorableActivityInfo favorableActivity = FavorableActivityBLL.Read(DateTime.Now, DateTime.Now, 0);

            if (favorableActivity.Id > 0)
            {
                if (("," + favorableActivity.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && Sessions.ProductTotalPrice >= favorableActivity.OrderProductMoney)
                {
                    switch (favorableActivity.ReduceWay)
                    {
                    case (int)FavorableMoney.Money:
                        favorableMoney += favorableActivity.ReduceMoney;
                        break;

                    case (int)FavorableMoney.Discount:
                        favorableMoney += Sessions.ProductTotalPrice * (10 - favorableActivity.ReduceDiscount) / 10;
                        break;

                    default:
                        break;
                    }
                    if (favorableActivity.ShippingWay == (int)FavorableShipping.Free && ShippingRegionBLL.IsRegionIn(regionID, favorableActivity.RegionId))
                    {
                        favorableMoney += shippingMoney;
                    }
                }
            }
            ResponseHelper.Write(shippingMoney.ToString() + "|" + favorableMoney.ToString());
            ResponseHelper.End();
        }
示例#16
0
        /// <summary>
        /// 订单操作时候,发送通知(Email,Message)的操作
        /// </summary>
        protected string OrderOperateSendEmail(OrderInfo order, OrderOperate orderOperate)
        {
            string result        = string.Empty;
            string key           = string.Empty;
            int    isSendNotice  = (int)BoolType.False;
            int    isSendEmail   = (int)BoolType.False;
            int    isSendMessage = (int)BoolType.False;

            switch (orderOperate)
            {
            case OrderOperate.Pay:
                isSendNotice  = ShopConfig.ReadConfigInfo().PayOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().PayOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().PayOrderMsg;
                key           = "PayOrder";
                break;

            case OrderOperate.Cancle:
                isSendNotice  = ShopConfig.ReadConfigInfo().CancleOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().CancleOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().CancleOrderMsg;
                key           = "CancleOrder";
                break;

            case OrderOperate.Check:
                isSendNotice  = ShopConfig.ReadConfigInfo().CheckOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().CheckOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().CheckOrderMsg;
                key           = "CheckOrder";
                break;

            case OrderOperate.Send:
                isSendNotice  = ShopConfig.ReadConfigInfo().SendOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().SendOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().SendOrderMsg;
                key           = "SendOrder";
                break;

            case OrderOperate.Received:
                isSendNotice  = ShopConfig.ReadConfigInfo().ReceivedOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().ReceivedOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().ReceivedOrderMsg;
                key           = "ReceivedOrder";
                break;

            case OrderOperate.Change:
                isSendNotice  = ShopConfig.ReadConfigInfo().ChangeOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().ChangeOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().ChangeOrderMsg;
                key           = "ChangeOrder";
                break;

            case OrderOperate.Return:
                isSendNotice  = ShopConfig.ReadConfigInfo().ReturnOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().ReturnOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().ReturnOrderMsg;
                key           = "ReturnOrder";
                break;

            case OrderOperate.Back:
                isSendNotice  = ShopConfig.ReadConfigInfo().BackOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().BackOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().BackOrderMsg;
                key           = "BackOrder";
                break;

            case OrderOperate.Refund:
                isSendNotice  = ShopConfig.ReadConfigInfo().RefundOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().RefundOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().RefundOrderMsg;
                key           = "RefundOrder";
                break;

            default:
                break;
            }
            if (isSendNotice == (int)BoolType.True && key != string.Empty)
            {
                if (isSendEmail == (int)BoolType.True)
                {//发邮件
                    try
                    {
                        EmailContentInfo    emailContent    = EmailContentHelper.ReadSystemEmailContent(key);
                        EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                        emailSendRecord.Title     = emailContent.EmailTitle;
                        emailSendRecord.Content   = emailContent.EmailContent.Replace("$UserName$", order.UserName).Replace("$OrderNumber$", order.OrderNumber).Replace("$PayName$", order.PayName).Replace("$ShippingName$", ShippingBLL.Read(order.ShippingId).Name).Replace("$ShippingNumber$", order.ShippingNumber).Replace("$ShippingDate$", order.ShippingDate.ToString("yyyy-MM-dd"));
                        emailSendRecord.IsSystem  = (int)BoolType.True;
                        emailSendRecord.EmailList = order.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 = "通知邮件已发送。";
                    }
                    catch {
                        result = "未发送通知邮件。";
                    }
                }
                if (isSendMessage == (int)BoolType.True)
                {//发短信
                    result += "未发送通知短信。";
                }
            }
            return(result);
        }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            { //检查待付款订单是否超时失效,超时则更新为失效状态
                OrderBLL.CheckOrderPayTime();
                int orderId = RequestHelper.GetQueryString <int>("Id");
                sendPoint = OrderBLL.ReadOrderSendPoint(orderId);
                if (orderId != int.MinValue)
                {
                    CheckAdminPower("ReadOrder", PowerCheckType.Single);
                    order          = OrderBLL.Read(orderId);
                    order.UserName = System.Web.HttpUtility.UrlDecode(order.UserName, System.Text.Encoding.UTF8);
                    int isCod = PayPlugins.ReadPayPlugins(order.PayKey).IsCod;
                    if ((order.OrderStatus == (int)OrderStatus.WaitPay || order.OrderStatus == (int)OrderStatus.WaitCheck && isCod == (int)BoolType.True) && order.IsActivity == (int)BoolType.False)
                    {
                        canEdit = true;
                    }
                    orderActionList = OrderActionBLL.ReadList(orderId);
                    ShowButton(order);

                    #region 获取快递信息
                    if (order.OrderStatus == (int)OrderStatus.HasShipping)
                    {
                        ShippingInfo tempShipping = ShippingBLL.Read(order.ShippingId);

                        string show = RequestHelper.GetQueryString <string>("show");

                        //string apiurl = "http://api.kuaidi100.com/api?id=2815b2d431fdfd26&com=" + typeCom + "&nu=" + nu + "&show=" + show + "&muti=1&order=asc";
                        string apiurl = "http://www.kuaidi100.com/applyurl?key=2815b2d431fdfd26&com=" + tempShipping.ShippingCode + "&nu=" + order.ShippingNumber + "&show=" + show + "&muti=1&order=desc";
                        //Response.Write (apiurl);
                        WebRequest   request  = WebRequest.Create(@apiurl);
                        WebResponse  response = request.GetResponse();
                        Stream       stream   = response.GetResponseStream();
                        Encoding     encode   = Encoding.UTF8;
                        StreamReader reader   = new StreamReader(stream, encode);

                        shippingLink = reader.ReadToEnd();
                    }
                    #endregion

                    //正在处理中的退款订单或商品
                    orderRefundList = OrderRefundBLL.ReadListValid(orderId);
                    //有正在处理中的退款订单或商品,禁用功能按钮
                    if (orderRefundList.Count(k => !OrderRefundBLL.HasReturn(k.Status)) > 0)
                    {
                        divOperate.Visible = false;
                        divNotice.Visible  = true;
                        lblNotice.Text     = "该订单有正在处理中的退款订单或商品...";
                    }
                }
                //如果付款操作,发送signalr消息
                if (RequestHelper.GetQueryString <int>("paysuccess") == 1)
                {
                    IHubContext chat = GlobalHost.ConnectionManager.GetHubContext <PushHub>();
                    chat.Clients.All.sendMessage(1);
                }
            }

            //不支持退货和退款操作,如果要退货退款,请线下操作
            ReturnButton.Visible = false;
        }
示例#18
0
        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();
            }
        }
示例#19
0
        /// <summary>
        /// 发送订单支付成功通知
        /// </summary>
        protected void SendPayOrderMsg(OrderInfo order)
        {
            int    isSendNotice  = ShopConfig.ReadConfigInfo().PayOrder;
            int    isSendEmail   = ShopConfig.ReadConfigInfo().PayOrderEmail;
            int    isSendMessage = ShopConfig.ReadConfigInfo().PayOrderMsg;
            string key           = "PayOrder";

            if (isSendNotice == (int)BoolType.True)
            {
                if (isSendEmail == (int)BoolType.True)
                {//发邮件
                    try
                    {
                        EmailContentInfo    emailContent    = EmailContentHelper.ReadSystemEmailContent(key);
                        EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                        emailSendRecord.Title     = emailContent.EmailTitle;
                        emailSendRecord.Content   = emailContent.EmailContent.Replace("$UserName$", order.UserName).Replace("$OrderNumber$", order.OrderNumber).Replace("$PayName$", order.PayName).Replace("$ShippingName$", ShippingBLL.Read(order.ShippingId).Name).Replace("$ShippingNumber$", order.ShippingNumber).Replace("$ShippingDate$", order.ShippingDate.ToString("yyyy-MM-dd"));
                        emailSendRecord.IsSystem  = (int)BoolType.True;
                        emailSendRecord.EmailList = order.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 = "通知邮件已发送。";
                    }
                    catch
                    {
                        //result = "未发送通知邮件。";
                    }
                }
                if (isSendMessage == (int)BoolType.True)
                {//发短信
                 //result += "未发送通知短信。";
                }
            }
        }
示例#20
0
        private void Submit()
        {
            /*-----------重新验证选择的商品------------------------------------------*/
            checkCart = StringHelper.AddSafe(RequestHelper.GetForm <string>("CheckCart"));
            int[]  cartIds          = Array.ConvertAll <string, int>(checkCart.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
            string checkCartCookies = HttpUtility.UrlDecode(CookiesHelper.ReadCookieValue("CheckCart"));

            if (checkCart != checkCartCookies)
            {
                ResponseHelper.Write("error|购买商品发生了变化,请重新提交|/cart.html");
                ResponseHelper.End();
            }

            if (string.IsNullOrEmpty(checkCart) || cartIds.Length < 1)
            {
                ResponseHelper.Write("error|请选择需要购买的商品|/cart.html");
                ResponseHelper.End();
            }
            /*----------------------------------------------------------------------*/

            /*-----------读取购物车清单---------------------------------------------*/
            List <CartInfo> cartList = CartBLL.ReadList(base.UserId);

            cartList = cartList.Where(k => cartIds.Contains(k.Id)).ToList();
            if (cartList.Count <= 0)
            {
                ResponseHelper.Write("error|请选择需要购买的商品|/cart.html");
                ResponseHelper.End();
            }
            /*----------------------------------------------------------------------*/

            /*-----------必要性检查:收货地址,配送方式,支付方式-------------------*/
            var address = new UserAddressInfo {
                Id = RequestHelper.GetForm <int>("address_id")
            };
            var shipping = new ShippingInfo {
                Id = RequestHelper.GetForm <int>("ShippingId")
            };
            var pay = new PayPluginsInfo {
                Key = StringHelper.AddSafe(RequestHelper.GetForm <string>("pay"))
            };
            //订单优惠活动
            var favor = new FavorableActivityInfo {
                Id = RequestHelper.GetForm <int>("FavorableActivity")
            };
            //商品优惠
            var productfavor = new FavorableActivityInfo {
                Id = RequestHelper.GetForm <int>("ProductFavorableActivity")
            };
            bool reNecessaryCheck = false;

doReNecessaryCheck:
            if (address.Id < 1)
            {
                ResponseHelper.Write("error|请选择收货地址|");
                ResponseHelper.End();
            }
            if (shipping.Id < 1)
            {
                ResponseHelper.Write("error|请选择配送方式|");
                ResponseHelper.End();
            }
            if (string.IsNullOrEmpty(pay.Key))
            {
                ResponseHelper.Write("error|请选择支付方式|");
                ResponseHelper.End();
            }

            //读取数据库中的数据,进行重复验证
            if (!reNecessaryCheck)
            {
                address  = UserAddressBLL.Read(address.Id, base.UserId);
                shipping = ShippingBLL.Read(shipping.Id);
                pay      = PayPlugins.ReadPayPlugins(pay.Key);

                reNecessaryCheck = true;
                goto doReNecessaryCheck;
            }
            /*----------------------------------------------------------------------*/

            /*-----------商品清单、商品总价、邮费价格、库存检查---------------------*/
            var     user = UserBLL.ReadUserMore(base.UserId);
            decimal productMoney = 0, pointMoney = 0;
            int     count = 0;
            //输入的兑换积分数
            var costPoint = RequestHelper.GetForm <int>("costPoint");

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

            foreach (var cart in cartList)
            {
                cart.Product = productList.FirstOrDefault(k => k.Id == cart.ProductId) ?? new ProductInfo();

                if (!string.IsNullOrEmpty(cart.StandardValueList))
                {
                    //使用规格的库存
                    var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList);
                    cart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount;
                    productMoney         += ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID) * (cart.BuyCount);
                }
                else
                {
                    cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount;
                    productMoney         += ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID) * (cart.BuyCount);
                }

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

            ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(shipping.Id, address.RegionId);
            decimal            shippingMoney  = ShippingRegionBLL.ReadShippingMoney(shipping.Id, shippingRegion.RegionId, cartList);

            /*----------------------------------------------------------------------*/
            #region 优惠券
            decimal        couponMoney   = 0;
            string         userCouponStr = RequestHelper.GetForm <string>("UserCoupon");
            UserCouponInfo userCoupon    = new UserCouponInfo();
            if (userCouponStr != string.Empty)
            {
                int couponID = 0;
                if (int.TryParse(userCouponStr.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0], out couponID))
                {
                    userCoupon = UserCouponBLL.Read(couponID, base.UserId);
                    if (userCoupon.UserId == base.UserId && userCoupon.IsUse == 0)
                    {
                        CouponInfo tempCoupon = CouponBLL.Read(userCoupon.CouponId);
                        if (tempCoupon.UseMinAmount <= productMoney)
                        {
                            couponMoney = CouponBLL.Read(userCoupon.CouponId).Money;
                        }
                        else
                        {
                            ResponseHelper.Write("error|结算金额小于该优惠券要求的最低消费的金额|");
                            ResponseHelper.End();
                        }
                    }
                }
            }
            #endregion
            #region 如果开启了:使用积分抵现,计算积分抵现的现金金额
            if (ShopConfig.ReadConfigInfo().EnablePointPay == 1)
            {
                if (costPoint > user.PointLeft || costPoint < 0)
                {
                    ResponseHelper.Write("error|输入的兑换积分数[" + costPoint + "]错误,请检查|");
                    ResponseHelper.End();
                }
                if (costPoint > 0)
                {
                    var PointToMoneyRate = ShopConfig.ReadConfigInfo().PointToMoney;
                    pointMoney = costPoint * (decimal)PointToMoneyRate / 100;
                }
            }
            #endregion
            #region 结算商品优惠金额
            decimal productfavorableMoney = 0;
            var     theFavor = FavorableActivityBLL.Read(productfavor.Id);
            if (theFavor.Id > 0)
            {
                decimal tmoney = 0;
                foreach (var tmpcart in cartList)
                {
                    tmpcart.Product = productList.FirstOrDefault(k => k.Id == tmpcart.ProductId) ?? new ProductInfo();
                    if (tmpcart.Product.ClassId.IndexOf(theFavor.ClassIds) > -1)
                    {
                        if (!string.IsNullOrEmpty(tmpcart.StandardValueList))
                        {
                            //使用规格的库存
                            var standardRecord = ProductTypeStandardRecordBLL.Read(tmpcart.ProductId, tmpcart.StandardValueList);
                            tmpcart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount;
                            tmpcart.Price            = ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID);
                            tmoney += tmpcart.Price * tmpcart.BuyCount;
                        }
                        else
                        {
                            tmpcart.Price = ProductBLL.GetCurrentPrice(tmpcart.Product.SalePrice, base.GradeID);
                            tmoney       += tmpcart.Price * tmpcart.BuyCount;
                        }
                    }
                }
                switch (theFavor.ReduceWay)
                {
                case (int)FavorableMoney.Money:
                    productfavorableMoney += theFavor.ReduceMoney;
                    break;

                case (int)FavorableMoney.Discount:
                    productfavorableMoney += tmoney * (100 - theFavor.ReduceDiscount) / 100;
                    break;

                default:
                    break;
                }
            }
            #endregion
            #region 计算订单优惠活动金额
            decimal favorableMoney = 0;
            favor = FavorableActivityBLL.Read(favor.Id);
            if (favor.Id > 0)
            {
                if (("," + favor.UserGrade + ",").IndexOf("," + base.GradeID.ToString() + ",") > -1 && productMoney >= favor.OrderProductMoney)
                {
                    switch (favor.ReduceWay)
                    {
                    case (int)FavorableMoney.Money:
                        favorableMoney += favor.ReduceMoney;
                        break;

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

                    default:
                        break;
                    }
                    if (favor.ShippingWay == (int)FavorableShipping.Free && ShippingRegionBLL.IsRegionIn(address.RegionId, favor.RegionId))
                    {
                        favorableMoney += shippingMoney;
                    }
                }
            }
            #endregion
            /*-----------应付总价---------------------------------------------------*/
            decimal payMoney = productMoney + shippingMoney - couponMoney - pointMoney - favorableMoney - productfavorableMoney;
            /*----------------------------------------------------------------------*/

            /*-----------检查金额---------------------------------------------------*/
            if (payMoney <= 0)
            {
                ResponseHelper.Write("error|金额有错误,请重新检查|");
                ResponseHelper.End();
            }
            /*----------------------------------------------------------------------*/


            /*-----------组装基础订单模型,循环生成订单-----------------------------*/
            OrderInfo order = new OrderInfo();
            order.ProductMoney = productMoney;
            order.OrderNumber  = ShopCommon.CreateOrderNumber();
            string         payKey     = RequestHelper.GetForm <string>("Pay");
            PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey);
            if (payMoney == 0 || payPlugins.IsCod == (int)BoolType.True)
            {
                order.OrderStatus = (int)OrderStatus.WaitCheck;
            }
            else
            {
                order.OrderStatus = (int)OrderStatus.WaitPay;
            }
            order.Consignee      = address.Consignee;
            order.RegionId       = address.RegionId;
            order.Address        = address.Address;
            order.ZipCode        = address.ZipCode;
            order.Tel            = address.Tel;
            order.Mobile         = address.Mobile;
            order.InvoiceTitle   = RequestHelper.GetForm <string>("InvoiceTitle");
            order.InvoiceContent = RequestHelper.GetForm <string>("InvoiceContent");
            order.GiftMessige    = RequestHelper.GetForm <string>("GiftMessige");
            order.Email          = CookiesHelper.ReadCookieValue("UserEmail");
            order.ShippingId     = shipping.Id;
            order.ShippingDate   = RequestHelper.DateNow;
            order.ShippingMoney  = shippingMoney;
            order.CouponMoney    = couponMoney;
            order.Point          = costPoint;
            order.PointMoney     = pointMoney;
            order.FavorableMoney = favorableMoney + productfavorableMoney;
            order.Balance        = 0;
            order.PayKey         = pay.Key;
            order.PayName        = pay.Name;
            order.PayDate        = RequestHelper.DateNow;
            order.IsRefund       = (int)BoolType.False;
            order.AddDate        = RequestHelper.DateNow;
            order.IP             = ClientHelper.IP;
            order.UserId         = base.UserId;
            order.UserName       = base.UserName;
            order.UserMessage    = RequestHelper.GetForm <string>("userMessage");
            order.GiftId         = RequestHelper.GetForm <int>("GiftID");
            order.IsNoticed      = 0;
            int orderId = OrderBLL.Add(order);

            //添加订单产品
            foreach (var cart in cartList)
            {
                var orderDetail = new OrderDetailInfo();
                orderDetail.OrderId           = orderId;
                orderDetail.ProductId         = cart.ProductId;
                orderDetail.ProductName       = cart.ProductName;
                orderDetail.StandardValueList = cart.StandardValueList;
                orderDetail.ProductWeight     = cart.Product.Weight;
                if (!string.IsNullOrEmpty(cart.StandardValueList))
                {
                    var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList);
                    orderDetail.ProductPrice = ProductBLL.GetCurrentPrice(standardRecord.SalePrice, base.GradeID);
                }
                else
                {
                    orderDetail.ProductPrice = ProductBLL.GetCurrentPrice(cart.Product.SalePrice, base.GradeID);
                }

                orderDetail.BidPrice = cart.Product.BidPrice;
                orderDetail.BuyCount = cart.BuyCount;

                OrderDetailBLL.Add(orderDetail);
            }
            #region 更新优惠券状态--已使用
            //使用优惠券
            if (couponMoney > 0 && userCouponStr != "0|0")
            {
                userCoupon.IsUse   = (int)BoolType.True;
                userCoupon.OrderId = orderId;
                UserCouponBLL.Update(userCoupon);
            }
            #endregion
            #region 减少积分
            if (ShopConfig.ReadConfigInfo().EnablePointPay == 1 && costPoint > 0)
            {
                //减少积分
                UserAccountRecordInfo uarInfo = new UserAccountRecordInfo();
                uarInfo.RecordType = (int)AccountRecordType.Point;
                uarInfo.UserId     = base.UserId;
                uarInfo.UserName   = base.UserName;
                uarInfo.Note       = "支付订单:" + order.OrderNumber;
                uarInfo.Point      = -costPoint;
                uarInfo.Money      = 0;
                uarInfo.Date       = DateTime.Now;
                uarInfo.IP         = ClientHelper.IP;
                UserAccountRecordBLL.Add(uarInfo);
            }
            #endregion
            /*-----------更改产品库存订单数量---------------------------------------*/
            ProductBLL.ChangeOrderCountByOrder(orderId, ChangeAction.Plus);
            /*----------------------------------------------------------------------*/

            /*-----------删除购物车中已下单的商品-----------------------------------*/
            CartBLL.Delete(cartIds, base.UserId);
            CookiesHelper.DeleteCookie("CheckCart");
            /*----------------------------------------------------------------------*/

            ResponseHelper.Write("ok||/Finish.html?id=" + orderId);
            ResponseHelper.End();
        }
示例#21
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");
        }