Beispiel #1
0
        protected override void PageLoad()
        {
            base.PageLoad();
            string id = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("id"));

            if (base.UserId <= 0)
            {
                ResponseHelper.Redirect("/user/login.html?RedirectUrl=/finish.html?id=" + id);
                ResponseHelper.End();
            }

            int[] ids = new int[] { };
            try
            {
                ids = Array.ConvertAll <string, int>(id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
            }
            catch { }

            var orders = OrderBLL.ReadList(ids, base.UserId);

            if (orders.Count > 0)
            {
                totalMoney   = orders.Sum(k => k.ProductMoney + k.ShippingMoney);
                balanceMoney = orders.Sum(k => k.Balance);
                payMoney     = orders.Sum(k => k.ProductMoney + k.ShippingMoney - k.Balance);

                payPlugins = PayPlugins.ReadPayPlugins(orders[0].PayKey);
            }

            Title = "订单完成";
        }
Beispiel #2
0
        protected void AddUserRecharge()
        {
            string  content     = string.Empty;
            decimal queryString = RequestHelper.GetQueryString <decimal>("Money");
            string  key         = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("PayKey"));

            if ((queryString <= 0M) || (key == string.Empty))
            {
                content = "请填写金额和选择支付方式";
            }
            else
            {
                UserRechargeInfo userRecharge = new UserRechargeInfo();
                Random           random       = new Random();
                userRecharge.Number       = RequestHelper.DateNow.ToString("yyMMddhh") + random.Next(0x3e8, 0x270f);
                userRecharge.Money        = queryString;
                userRecharge.PayKey       = key;
                userRecharge.PayName      = PayPlugins.ReadPayPlugins(key).Name;
                userRecharge.RechargeDate = RequestHelper.DateNow;
                userRecharge.RechargeIP   = ClientHelper.IP;
                userRecharge.IsFinish     = 0;
                userRecharge.UserID       = base.UserID;
                userRecharge.UserName     = base.UserName;
                content = UserRechargeBLL.AddUserRecharge(userRecharge).ToString();
            }
            ResponseHelper.Write(content);
            ResponseHelper.End();
        }
Beispiel #3
0
        /// <summary>
        /// 手机读取订单用户操作
        /// </summary>
        /// <param name="orderID">订单ID</param>
        /// <param name="checkStatus">订单状态</param>
        /// <param name="payKey">支付方式关键字</param>
        /// <returns></returns>
        public static string ReadOrderUserOperate2(int orderID, int orderStatus, string payKey)
        {
            string    result = string.Empty;
            OrderInfo order  = OrderBLL.Read(orderID);

            if (order.IsDelete == (int)BoolType.False)
            {
                switch (orderStatus)
                {
                case (int)OrderStatus.WaitPay:
                    result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\">取消</a>";
                    if (payKey == "WxPay")
                    {
                        if (RequestHelper.UserAgent() && RequestHelper.IsMicroMessenger())
                        {
                            result += " <a href=\"/Plugins/Pay/WxPay/Pay.aspx?order_id=" + orderID.ToString() + "\" class=\"red\" style=\"background-color:#da251a;color:#fff;\">付款</a>";
                        }
                        else
                        {
                            result += " <a href=\"/mobile/finish.html?ID=" + orderID.ToString() + "\" class=\"red\" style=\"background-color:#da251a;color:#fff;\">付款</a>";
                        }
                    }
                    else
                    {
                        if (PayPlugins.ReadPayPlugins(payKey).IsOnline == (int)BoolType.True)
                        {
                            result += " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?order_id=" + orderID.ToString() + "\" class=\"red\" style=\"background-color:#da251a;color:#fff;\">付款</a>";
                        }
                    }
                    break;

                case (int)OrderStatus.WaitCheck:
                    if (PayPlugins.ReadPayPlugins(payKey).IsOnline != (int)BoolType.True)
                    {
                        result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\" >取消</a>";
                    }
                    break;

                case (int)OrderStatus.NoEffect:
                case (int)OrderStatus.Shipping:
                    break;

                case (int)OrderStatus.HasShipping:
                    result  = "<a href=\"/mobile/User/ShippingList.html?OrderID=" + orderID + "\" class=\"red\">查看物流</a>";
                    result += "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderStatus.HasShipping + ")\">确定收货</a>";
                    break;

                case (int)OrderStatus.ReceiveShipping:
                    result = "<a href=\"/Mobile/user/CommentOrderProduct-O" + orderID + ".html\" >评论</a>";
                    break;

                case (int)OrderStatus.HasReturn:
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
Beispiel #4
0
        public static string ReadOrderUserOperate(int orderID, int orderStatus, string payKey)
        {
            string str = string.Empty;

            switch (orderStatus)
            {
            case 1:
                str = string.Concat(new object[] { "<a href=\"javascript:orderOperate(", orderID, ",", 1, ")\">取消</a>" });
                if (PayPlugins.ReadPayPlugins(payKey).IsOnline == 1)
                {
                    string str3 = str;
                    str = str3 + " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?Action=PayOrder&OrderID=" + orderID.ToString() + "\" target=\"_blank\">付款</a>";
                }
                return(str);

            case 2:
                return(string.Concat(new object[] { "<a href=\"javascript:orderOperate(", orderID, ",", 2, ")\">取消</a>" }));

            case 3:
            case 4:
                return(str);

            case 5:
                return(string.Concat(new object[] { "<a href=\"javascript:orderOperate(", orderID, ",", 5, ")\">确定收货</a>" }));

            case 6:
            case 7:
                return(str);
            }
            return(str);
        }
Beispiel #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         BindControl(PayPlugins.ReadPayPluginsList(), RecordList);
     }
 }
        protected void AddUserRecharge()
        {
            decimal money  = RequestHelper.GetForm <decimal>("money");
            string  payKey = StringHelper.AddSafe(RequestHelper.GetForm <string>("pay"));

            if (money <= 0)
            {
                ResponseHelper.Write("error|请填写金额");
                ResponseHelper.End();
            }
            if (string.IsNullOrEmpty(payKey))
            {
                ResponseHelper.Write("error|请选择支付方式");
                ResponseHelper.End();
            }

            UserRechargeInfo userRecharge = new UserRechargeInfo();
            Random           rd           = new Random();

            userRecharge.Number       = RequestHelper.DateNow.ToString("yyMMddhh") + rd.Next(1000, 9999);
            userRecharge.Money        = money;
            userRecharge.PayKey       = payKey;
            userRecharge.PayName      = PayPlugins.ReadPayPlugins(payKey).Name;
            userRecharge.RechargeDate = RequestHelper.DateNow;
            userRecharge.RechargeIP   = ClientHelper.IP;
            userRecharge.IsFinish     = (int)BoolType.False;
            userRecharge.UserId       = base.UserId;
            int id = UserRechargeBLL.Add(userRecharge);

            ResponseHelper.Write("ok|" + id);
            ResponseHelper.End();
        }
        protected override void PageLoad()
        {
            base.PageLoad();
            action = RequestHelper.GetQueryString <string>("Action");
            switch (action)
            {
            case "Read":
                userRechargeList = UserRechargeBLL.ReadList(base.UserId);
                break;

            case "Add":
                payPluginsList = PayPlugins.ReadRechargePayPluginsList();
                //webservice
                //var account = WebService.Account.GetAccount();
                //moneyLeft = account.Zacc;
                break;

            case "AddUserRecharge":
                AddUserRecharge();
                break;

            default:
                break;
            }
        }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         base.CheckAdminPower("ReadPay", PowerCheckType.Single);
         base.BindControl(PayPlugins.ReadPayPluginsList(), this.RecordList);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            ClearCache();

            //订单产品操作
            string action = RequestHelper.GetQueryString <string>("Action");

            if (!string.IsNullOrEmpty(action))
            {
                int       tempOrderId = RequestHelper.GetQueryString <int>("OrderId");
                OrderInfo tempOrder   = OrderBLL.Read(tempOrderId);
                int       isCod       = PayPlugins.ReadPayPlugins(tempOrder.PayKey).IsCod;
                if ((tempOrder.OrderStatus == (int)OrderStatus.WaitPay || tempOrder.OrderStatus == (int)OrderStatus.WaitCheck && isCod == (int)BoolType.True) && (tempOrder.IsActivity == (int)OrderKind.Common || tempOrder.IsActivity == (int)OrderKind.GroupBuy))
                {
                    switch (action)
                    {
                    case "DeleteOrderProduct":
                        DeleteOrderProduct();
                        break;

                    case "ChangeOrderProductBuyCount":
                        ChangeOrderProductBuyCount();
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    ResponseHelper.Write("订单已经审核,无法修改");
                    ResponseHelper.End();
                }
            }

            //读取订单产品
            int orderId = RequestHelper.GetQueryString <int>("Id");

            if (orderId != int.MinValue)
            {
                CheckAdminPower("ReadOrder", PowerCheckType.Single);
                order = OrderBLL.Read(orderId);
                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)OrderKind.Common || order.IsActivity == (int)OrderKind.GroupBuy))
                {
                    canEdit = true;
                }
                orderDetailList = OrderDetailBLL.ReadList(orderId);

                foreach (OrderDetailInfo orderDetail in orderDetailList)
                {
                    totalProductCount += orderDetail.BuyCount;
                    totalWeight       += orderDetail.BuyCount * orderDetail.ProductWeight;
                    totalPoint        += orderDetail.BuyCount * orderDetail.SendPoint;
                }
            }
        }
Beispiel #10
0
        public static string ReadOrderUserOperate3(int orderID, int orderStatus, string payKey)
        {
            string    result = string.Empty;
            OrderInfo order  = OrderBLL.Read(orderID);

            if (order.IsDelete == (int)BoolType.False)
            {
                switch (orderStatus)
                {
                case (int)OrderStatus.WaitPay:
                    result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\">取消</a>";
                    if (payKey == "WxPay")
                    {
                        result += " <a href=\"/Plugins/Pay/WxPay/Pay.aspx?order_id=" + orderID.ToString() + "\" target=\"_blank\"  style=\"display:inline-block;background-color:#da251a;padding:0px 3px;color:#fff;\">付款</a>";
                    }
                    else
                    {
                        if (PayPlugins.ReadPayPlugins(payKey).IsOnline == (int)BoolType.True)
                        {
                            result += " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?order_id=" + orderID.ToString() + "\" target=\"_blank\" style=\"display:inline-block;background-color:#da251a;padding:0px 3px;color:#fff;\">付款</a>";
                        }
                    }
                    break;

                case (int)OrderStatus.WaitCheck:
                    if (PayPlugins.ReadPayPlugins(payKey).IsOnline != (int)BoolType.True)
                    {
                        result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderOperate.Cancle + ")\" >取消</a>";
                    }
                    break;

                case (int)OrderStatus.NoEffect:
                case (int)OrderStatus.Shipping:
                    break;

                case (int)OrderStatus.HasShipping:
                    result = "<a href=\"javascript:orderOperate(" + orderID + "," + (int)OrderStatus.HasShipping + ")\">确定收货</a>";
                    break;

                case (int)OrderStatus.ReceiveShipping:
                    result = "<a href=\"/Mobile/User/CommentOrderProduct-O" + orderID + ".html\" target\"_blank\">评论</a>";
                    break;

                case (int)OrderStatus.HasReturn:
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
Beispiel #11
0
        protected override void PageLoad()
        {
            base.PageLoad();
            if ((ShopConfig.ReadConfigInfo().AllowAnonymousAddCart == 1) && (base.UserID == 0))
            {
                ResponseHelper.Redirect("/User/Login.aspx");
                ResponseHelper.End();
            }
            int queryString = RequestHelper.GetQueryString <int>("ID");

            this.order      = OrderBLL.ReadOrder(queryString, base.UserID);
            this.payPlugins = PayPlugins.ReadPayPlugins(this.order.PayKey);
            base.Title      = "¶©µ¥Íê³É";
        }
Beispiel #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string key = RequestHelper.GetQueryString <string>("Key");
         if (key != string.Empty)
         {
             CheckAdminPower("ReadPay", PowerCheckType.Single);
             payPlugins       = PayPlugins.ReadPayPlugins(key);
             Description.Text = payPlugins.Description;
             IsEnabled.Text   = payPlugins.IsEnabled.ToString();
             PayPlugins.ReadCanChangePayPlugins(key, ref nameDic, ref valueDic, ref selectValueDic);
         }
     }
 }
Beispiel #13
0
        protected override void PageLoad()
        {
            base.PageLoad();
            int id = RequestHelper.GetQueryString <int>("id");

            if (base.UserId <= 0)
            {
                ResponseHelper.Redirect("/Mobile/User/login.html?RedirectUrl=/Mobile/finish.html?id=" + id);
                ResponseHelper.End();
            }

            order      = OrderBLL.Read(id, base.UserId);
            payPlugins = PayPlugins.ReadPayPlugins(order.PayKey);

            Title = "订单完成";
        }
Beispiel #14
0
        /// <summary>
        /// 处理可配置的文件
        /// </summary>
        protected void HanlerCanChangPayPlugins(string key)
        {
            Dictionary <string, string> configDic = new Dictionary <string, string>();
            string nameList = RequestHelper.GetForm <string>("ConfigNameList");

            foreach (string name in nameList.Split('|'))
            {
                if (name != string.Empty)
                {
                    configDic.Add(name, RequestHelper.GetForm <string>(name).Trim());
                }
            }
            configDic.Add("Description", Description.Text.Trim());
            configDic.Add("IsEnabled", IsEnabled.Text.Trim());
            PayPlugins.UpdatePayPlugins(key, configDic);
        }
Beispiel #15
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 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal productTotalPrice = Sessions.ProductTotalPrice;
            string  key = RequestHelper.GetForm <string>("Pay");

            //默认选择支付宝AliPay
            if (UserAgentHelper.IsWx(Request.UserAgent))
            {
                key = "WxPay";
            }
            else
            {
                key = "AliPay";
            }
            PayPluginsInfo info  = PayPlugins.ReadPayPlugins(key);
            OrderInfo      order = new OrderInfo();

            order.PayKey      = key;
            order.PayName     = info.Name;
            order.OrderNumber = ShopCommon.CreateOrderNumber();
            if (info.IsCod == 1)
            {
                order.OrderStatus = 2;
            }
            else
            {
                order.OrderStatus = 1;
            }
            order.OrderNote    = string.Empty;
            order.ProductMoney = productTotalPrice;
            //order.PayDate = RequestHelper.DateNow;
            order.UserID = UserID;
            //order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            this.AddOrderProduct(orderID);
            if (order.OrderStatus == (int)OrderStatus.WaitPay && info.IsOnline == (int)BoolType.True)
            {
                ResponseHelper.Redirect("/Plugins/Pay/" + key + "/Pay.aspx?OrderID=" + orderID + "&Action=PayOrder");
            }
        }
        /// <summary>
        /// 退款按钮点击方法【不支持】
        /// </summary>
        protected void RefundButton_Click(object sender, EventArgs e)
        {
            OrderInfo order = ButtoStart();
            //余额处理
            decimal money = order.Balance;
            int     isCod = PayPlugins.ReadPayPlugins(order.PayKey).IsCod;

            if (order.OrderStatus == (int)OrderStatus.HasReturn && isCod == (int)BoolType.False)
            {
                money += OrderBLL.ReadNoPayMoney(order);
            }
            else if (order.OrderStatus == (int)OrderStatus.NoEffect && OrderActionBLL.ReadLast(order.Id, order.OrderStatus).StartOrderStatus == (int)OrderStatus.WaitCheck && isCod == (int)BoolType.False)
            {
                money += OrderBLL.ReadNoPayMoney(order);
            }
            if (money > 0)
            {
                var accountRecord = new UserAccountRecordInfo
                {
                    RecordType = (int)AccountRecordType.Money,
                    Money      = money,
                    Point      = 0,
                    Date       = DateTime.Now,
                    IP         = ClientHelper.IP,
                    Note       = "退还订单:" + order.OrderNumber + "的金额",
                    UserId     = order.UserId,
                    UserName   = order.UserName
                };
                UserAccountRecordBLL.Add(accountRecord);
            }
            //更新订单
            int startOrderStatus = order.OrderStatus;

            order.OrderStatus = (int)order.OrderStatus;
            order.Balance     = 0;
            order.CouponMoney = 0;
            order.IsRefund    = (int)BoolType.True;
            ButtonEnd(order, Note.Text, OrderOperate.Refund, startOrderStatus);
        }
Beispiel #18
0
        protected override void PageLoad()
        {
            base.PageLoad();
            this.action = RequestHelper.GetQueryString <string>("Action");
            string action = this.action;

            if (action != null)
            {
                if (!(action == "Read"))
                {
                    if (action == "Add")
                    {
                        this.payPluginsList = PayPlugins.ReadRechargePayPluginsList();
                        this.moneyLeft      = UserBLL.ReadUserMore(base.UserID).MoneyLeft;
                    }
                    else if (action == "AddUserRecharge")
                    {
                        this.AddUserRecharge();
                    }
                }
                else
                {
                    int queryString = RequestHelper.GetQueryString <int>("Page");
                    if (queryString < 1)
                    {
                        queryString = 1;
                    }
                    int pageSize = 20;
                    int count    = 0;
                    UserRechargeSearchInfo userRecharge = new UserRechargeSearchInfo();
                    userRecharge.UserID             = base.UserID;
                    this.userRechargeList           = UserRechargeBLL.SearchUserRechargeList(queryString, pageSize, userRecharge, ref count);
                    this.ajaxPagerClass.CurrentPage = queryString;
                    this.ajaxPagerClass.PageSize    = pageSize;
                    this.ajaxPagerClass.Count       = count;
                }
            }
        }
Beispiel #19
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 #20
0
        /// <summary>
        /// 拆分不同的供应商商品,生成订单
        /// </summary>
        private List <int> SplitShopProduct(List <CartInfo> cartList, OrderInfo mainOrder)
        {
            List <int> orderIds = new List <int>();

            /*-----------根据ShopId分组---------------------------------------------*/
            var shopIds = cartList.GroupBy(k => k.Product.ShopId).Select(k => k.Key).ToList();
            /*----------------------------------------------------------------------*/

            /*-----------积分抵扣额度、比率(不可使用积分)-----------------------------
             * decimal totalRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointTotalRate;
             * decimal pointRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointMoneyRate;
             * /*----------------------------------------------------------------------*/

            var pay = PayPlugins.ReadPayPlugins(mainOrder.PayKey);

            //
            //循环产生订单
            foreach (var shopId in shopIds)
            {
                var shopCartList = cartList.Where(k => k.Product.ShopId == shopId).ToList();

                /*-----------分拆后的订单价格---------------------------------------*/
                //运费 (去掉平均分配运费,根据供应商的不同来分别计算运费)
                //decimal shippingMoney = mainOrder.ShippingMoney / shopIds.Count;

                decimal shippingMoney = 0;
                //然后将分拆后的供应商商品,按单个商品独立计算运费(相同商品购买多个则叠加计算)
                ShippingInfo       shipping       = ShippingBLL.Read(mainOrder.ShippingId);
                ShippingRegionInfo shippingRegion = ShippingRegionBLL.SearchShippingRegion(mainOrder.ShippingId, mainOrder.RegionId);

                foreach (var shopCartSplit in shopCartList)
                {
                    shippingMoney += ShippingRegionBLL.ReadShippingMoney(shipping, shippingRegion, shopCartSplit);
                }

                //产品金额
                decimal productMoney = 0;
                shopCartList.ForEach(k => productMoney += k.BuyCount * k.Price);
                /*------------------------------------------------------------------*/

                decimal pointMoney = 0;
                int     point      = 0;

                /*-----------根据比率,分配积分抵扣金额(不可使用积分)----------------
                 * decimal pointMoney = 0;
                 * int point = 0;
                 * if (mainOrder.Point > 0)
                 * {
                 *  pointMoney = productMoney * totalRate;
                 *  point = (int)(pointMoney * pointRate);
                 *  if (point > mainOrder.Point)
                 *  {
                 *      point = mainOrder.Point;
                 *      pointMoney = Math.Round(point / pointRate, 2);
                 *  }
                 * }
                 * /*----------------------------------------------------------------------*/

                /*-----------应付总价---------------------------------------------------*/
                //decimal payMoney = productMoney + shippingMoney - pointMoney;
                decimal payMoney = productMoney + shippingMoney;
                /*----------------------------------------------------------------------*/

                /*-----------分配余额---------------------------------------------------*/
                decimal balance = 0;
                if (mainOrder.Balance > 0)
                {
                    balance = mainOrder.Balance;
                    if (balance > payMoney)
                    {
                        balance = payMoney;
                    }
                }
                payMoney -= balance;
                /*----------------------------------------------------------------------*/


                /*-----------添加订单---------------------------------------------------*/
                OrderInfo order = new OrderInfo();
                order.ShopId        = shopId;
                order.OrderNumber   = ShopCommon.CreateOrderNumber();
                order.IsActivity    = (int)BoolType.False;
                order.OrderStatus   = payMoney == 0 || pay.IsCod == (int)BoolType.True ? (int)OrderStatus.WaitCheck : (int)OrderStatus.WaitPay;
                order.ProductMoney  = productMoney;
                order.Consignee     = mainOrder.Consignee;
                order.RegionId      = mainOrder.RegionId;
                order.Address       = mainOrder.Address;
                order.ZipCode       = mainOrder.ZipCode;
                order.Tel           = mainOrder.Tel;
                order.Mobile        = mainOrder.Mobile;
                order.Email         = mainOrder.Email;
                order.ShippingId    = mainOrder.ShippingId;
                order.ShippingDate  = RequestHelper.DateNow;
                order.ShippingMoney = shippingMoney;
                order.Point         = point;
                order.PointMoney    = pointMoney;
                order.Balance       = balance;
                order.PayKey        = mainOrder.PayKey;
                order.PayName       = mainOrder.PayName;
                order.PayDate       = RequestHelper.DateNow;
                order.IsRefund      = (int)BoolType.False;
                order.UserMessage   = mainOrder.UserMessage;
                order.AddDate       = RequestHelper.DateNow;
                order.IP            = ClientHelper.IP;
                order.UserId        = base.UserId;
                order.UserName      = base.UserName;
                int orderId = OrderBLL.Add(order);

                //添加订单产品
                foreach (var cart in shopCartList)
                {
                    var orderDetail = new OrderDetailInfo();
                    orderDetail.OrderId       = orderId;
                    orderDetail.ProductId     = cart.ProductId;
                    orderDetail.ProductName   = cart.ProductName;
                    orderDetail.ProductWeight = cart.Product.Weight;
                    orderDetail.ProductPrice  = cart.Price;
                    orderDetail.BidPrice      = cart.Product.BidPrice;
                    orderDetail.BuyCount      = cart.BuyCount;

                    OrderDetailBLL.Add(orderDetail);
                }
                /*----------------------------------------------------------------------*/

                /*-----------使用余额、积分(余额消费记录更改到同步订单金额到图楼泛生活会员管理系统成功后,才予记录)
                 * if (balance > 0 && order.OrderStatus == (int)OrderStatus.WaitCheck)
                 * {
                 *  var accountRecord = new UserAccountRecordInfo
                 *  {
                 *      RecordType = (int)AccountRecordType.Money,
                 *      Money = -balance,
                 *      Point = 0,
                 *      Date = DateTime.Now,
                 *      IP = ClientHelper.IP,
                 *      Note = "支付订单:" + order.OrderNumber,
                 *      UserId = base.UserId,
                 *      UserName = base.UserName
                 *  };
                 *  UserAccountRecordBLL.Add(accountRecord);
                 * }
                 * ------------------------------------------------------------------------*/
                /*-----------不可使用积分-------------------------------------------------
                 * if (point > 0)
                 * {
                 *  var accountRecord = new UserAccountRecordInfo
                 *  {
                 *      RecordType = (int)AccountRecordType.Point,
                 *      Money = 0,
                 *      Point = -point,
                 *      Date = DateTime.Now,
                 *      IP = ClientHelper.IP,
                 *      Note = "支付订单:" + order.OrderNumber,
                 *      UserId = base.UserId,
                 *      UserName = base.UserName
                 *  };
                 *  UserAccountRecordBLL.Add(accountRecord);
                 * }
                 * ------------------------------------------------------------------------*/
                /*----------------------------------------------------------------------*/

                /*-----------更改产品库存订单数量---------------------------------------*/
                ProductBLL.ChangeOrderCountByOrder(orderId, ChangeAction.Plus);
                /*----------------------------------------------------------------------*/

                mainOrder.Point   -= point;
                mainOrder.Balance -= balance;
                orderIds.Add(orderId);
            }

            return(orderIds);
        }
Beispiel #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);
            }

            //检查金额
            decimal productMoney = 0;

            #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 favorableMoney = 0;
            decimal shippingMoney  = 0;
            #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;
            }
            //计算优惠费用
            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;
                    }
                }
            }
            #endregion

            decimal balance = RequestHelper.GetForm <decimal>("Balance");
            moneyLeft = UserBLL.ReadUserMore(base.UserId).MoneyLeft;
            if (balance > moneyLeft)
            {
                balance = 0;
                ScriptHelper.AlertFront("金额有错误,请重新检查", url);
            }


            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)
                    {
                        couponMoney = CouponBLL.Read(userCoupon.CouponId).Money;
                    }
                }
            }
            if (productMoney - favorableMoney + shippingMoney - balance - couponMoney < 0)
            {
                ScriptHelper.AlertFront("金额有错误,请重新检查", url);
            }
            //支付方式
            string         payKey     = RequestHelper.GetForm <string>("Pay");
            PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey);
            //添加订单
            OrderInfo order = new OrderInfo();
            order.OrderNumber = ShopCommon.CreateOrderNumber();
            order.IsActivity  = (int)BoolType.False;
            if (productMoney - favorableMoney + shippingMoney - balance - couponMoney == 0 || payPlugins.IsCod == (int)BoolType.True)
            {
                order.OrderStatus = (int)OrderStatus.WaitCheck;
            }
            else
            {
                order.OrderStatus = (int)OrderStatus.WaitPay;
            }
            order.OrderNote      = string.Empty;
            order.ProductMoney   = productMoney;
            order.Balance        = balance;
            order.FavorableMoney = favorableMoney;
            order.OtherMoney     = 0;
            order.CouponMoney    = couponMoney;
            order.Consignee      = consignee;
            SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass();
            order.RegionId = singleUnlimitClass.ClassID;
            order.Address  = address;
            order.ZipCode  = zipCode;
            order.Tel      = tel;
            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;
            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);
            }
            //使用优惠券
            string strUserCoupon = RequestHelper.GetForm <string>("UserCoupon");
            if (couponMoney > 0 && strUserCoupon != "0|0")
            {
                userCoupon.IsUse   = (int)BoolType.True;
                userCoupon.OrderId = orderID;
                UserCouponBLL.Update(userCoupon);
            }
            AddOrderProduct(orderID);
            //更改产品库存订单数量
            ProductBLL.ChangeOrderCountByOrder(orderID, ChangeAction.Plus);
            ResponseHelper.Redirect("/Mobile/Finish-I" + orderID.ToString() + ".html");
        }
Beispiel #22
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|购买商品发生了变化,请重新提交|" + isMobile + "/cart.html");
                ResponseHelper.End();
            }

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

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

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

            /*-----------必要性检查:收货地址,配送方式,支付方式-------------------*/
            var address = new UserAddressInfo {
                Id = RequestHelper.GetForm <int>("address_id")
            };
            var shipping = new ShippingInfo {
                Id = RequestHelper.GetForm <int>("ShippingId")
            };
            var pay = new PayPluginsInfo {
                Key = StringHelper.AddSafe(RequestHelper.GetForm <string>("pay"))
            };

            bool reNecessaryCheck = false;

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

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

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

            /*-----------商品清单、商品总价、邮费价格、库存检查---------------------*/
            decimal productMoney = 0;
            int     count        = 0;

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

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

                if (!string.IsNullOrEmpty(cart.StandardValueList))
                {
                    //使用规格的价格和库存
                    var standardRecord = ProductTypeStandardRecordBLL.Read(cart.ProductId, cart.StandardValueList);
                    cart.Price            = standardRecord.SalePrice;
                    cart.LeftStorageCount = standardRecord.Storage - standardRecord.OrderCount;
                }
                else
                {
                    cart.Price            = cart.Product.SalePrice;
                    cart.LeftStorageCount = cart.Product.TotalStorageCount - cart.Product.OrderCount;
                }

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

                productMoney += cart.BuyCount * cart.Price;
            }

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

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

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

            int     point      = 0;
            decimal pointMoney = 0;

            /*-----------计算积分金额(不可使用积分)-----------------------------------
             * decimal totalRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointTotalRate;
             * decimal pointRate = (decimal)ShopConfig.ReadConfigInfo().BuyPointMoneyRate;
             * int point = RequestHelper.GetForm<int>("point");
             * decimal pointMoney = 0;
             * if (totalRate > 0 && pointRate > 0 && point > 0)
             * {
             *  var member = WebService.Member.GetMember();
             *  decimal leftPoint = member.Point;
             *  if (point > leftPoint)
             *  {
             *      ResponseHelper.Write("error|您的积分不足|");
             *      ResponseHelper.End();
             *  }
             *  else
             *  {
             *      pointMoney = Math.Round(point / pointRate, 2);
             *
             *      if (pointMoney > productMoney * totalRate)
             *      {
             *          ResponseHelper.Write("error|" + "您最多可以使用 " + (productMoney * totalRate * pointRate) + " 积分|");
             *          ResponseHelper.End();
             *      }
             *  }
             * }
             * ------------------------------------------------------------------------*/

            /*-----------应付总价---------------------------------------------------*/
            //decimal payMoney = productMoney + shippingMoney - pointMoney;
            decimal payMoney = productMoney + shippingMoney;
            /*----------------------------------------------------------------------*/

            var user = UserBLL.Read(base.UserId);
            /*-----------计算图楼卡余额---------------------------------------------*/
            decimal balance = RequestHelper.GetForm <decimal>("money");

            if (balance > 0)
            {
                bool isSuccess; string msg;
                isSuccess = true;
                msg       = "";
                //var account = WebService.Account.GetAccount(user.CardNo, user.CardPwd, out isSuccess, out msg);
                if (!isSuccess)
                {
                    ResponseHelper.Write("error|" + msg + "|");
                    ResponseHelper.End();
                }

                if (balance > 0 /*(account.Zacc + account.Sacc)*/)
                {
                    ResponseHelper.Write("error|您的图楼卡余额不足|");
                    ResponseHelper.End();
                }
                else
                {
                    if (balance > payMoney)
                    {
                        ResponseHelper.Write("error|" + "您只需使用 " + payMoney + " 元即可支付订单|");
                        ResponseHelper.End();
                    }
                }
            }
            payMoney -= balance;
            /*----------------------------------------------------------------------*/

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

            /*-----------组装基础订单模型,循环生成订单-----------------------------*/
            OrderInfo order = new OrderInfo();

            order.ProductMoney  = productMoney;
            order.Consignee     = address.Consignee;
            order.RegionId      = address.RegionId;
            order.Address       = address.Address;
            order.ZipCode       = address.ZipCode;
            order.Tel           = address.Tel;
            order.Mobile        = address.Mobile;
            order.Email         = CookiesHelper.ReadCookieValue("UserEmail");
            order.ShippingId    = shipping.Id;
            order.ShippingDate  = RequestHelper.DateNow;
            order.ShippingMoney = shippingMoney;
            order.Point         = point;
            order.PointMoney    = pointMoney;
            order.Balance       = balance;
            order.PayKey        = pay.Key;
            order.PayName       = pay.Name;
            order.PayDate       = RequestHelper.DateNow;
            order.IsRefund      = (int)BoolType.False;
            order.UserMessage   = StringHelper.AddSafe(RequestHelper.GetForm <string>("msg"));
            order.AddDate       = RequestHelper.DateNow;
            order.IP            = ClientHelper.IP;
            order.UserId        = base.UserId;
            order.UserName      = base.UserName;

            //循环生成订单
            var orderIds = SplitShopProduct(cartList, order);
            /*----------------------------------------------------------------------*/

            var orders = OrderBLL.ReadList(orderIds.ToArray(), base.UserId);

            /*-----------如果使用了图楼卡支付,需同步到会员管理系统中---------------*/
            /*第二步,在订单付款操作(用户端)中,同步图楼卡余额*/
            if (balance > 0)
            {
                List <string[]> paras = new List <string[]>();
                foreach (var oo in orders)
                {
                    if (oo.Balance > 0 && oo.OrderStatus == (int)OrderStatus.WaitCheck)
                    {
                        string[] para = new string[2];
                        para[0] = oo.OrderNumber;
                        para[1] = oo.Balance.ToString();
                        paras.Add(para);
                    }
                }

                //如果有全额使用了图楼卡余额支付的订单,需同步到会员管理系统中
                if (paras.Count > 0)
                {
                    bool isSuccess; string msg;
                    isSuccess = true;
                    msg       = "";
                    //WebService.Account.Purchase(user.CardNo, user.CardPwd, paras, out isSuccess, out msg);

                    //同步失败,删除订单及相关信息
                    if (!isSuccess)
                    {
                        //删除订单、订单详细、订单状态相关数据
                        OrderBLL.Delete(orderIds.ToArray(), base.UserId);

                        //更改产品库存订单数量
                        foreach (var orderId in orderIds)
                        {
                            ProductBLL.ChangeOrderCountByOrder(orderId, ChangeAction.Minus);
                        }
                        ResponseHelper.Write("error|" + msg + "|");
                        ResponseHelper.End();
                    }
                    else
                    {
                        //记录用户余额消费记录
                        foreach (var par in paras)
                        {
                            var accountRecord = new UserAccountRecordInfo
                            {
                                RecordType = (int)AccountRecordType.Money,
                                Money      = -decimal.Parse(par[1]),
                                Point      = 0,
                                Date       = DateTime.Now,
                                IP         = ClientHelper.IP,
                                Note       = "支付订单:" + par[0],
                                UserId     = base.UserId,
                                UserName   = base.UserName
                            };
                            UserAccountRecordBLL.Add(accountRecord);
                        }
                    }
                }
            }
            /*----------------------------------------------------------------------*/

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

            /*如果所有订单均由图楼卡支付完成,则跳转到会员中心,否则跳转到支付提示页面*/
            if (orders.Count(k => k.OrderStatus == (int)OrderStatus.WaitPay) > 0)
            {
                ResponseHelper.Write("ok||/finish.html?id=" + string.Join(",", orders.Select(k => k.Id).ToArray()));
            }
            else
            {
                ResponseHelper.Write("ok||/user/index.html");
            }
            ResponseHelper.End();
            /*----------------------------------------------------------------------*/
        }
Beispiel #23
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 #24
0
        protected override void PostBack()
        {
            string url  = "/CheckOut.aspx";
            string str2 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));

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

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

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

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

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

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

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

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

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

            if ((num6 > 0M) && (str8 != "0|0"))
            {
                UserCouponInfo userCoupon = UserCouponBLL.ReadUserCoupon(Convert.ToInt32(str8.Split(new char[] { '|' })[0]), base.UserID);
                userCoupon.IsUse   = 1;
                userCoupon.OrderID = orderID;
                UserCouponBLL.UpdateUserCoupon(userCoupon);
            }
            this.AddOrderProduct(orderID);
            ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);
            ResponseHelper.Redirect("/Finish-I" + orderID.ToString() + ".aspx");
        }
Beispiel #25
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 #26
0
        /// <summary>
        /// 退款到账户余额及各支付渠道
        /// </summary>
        /// <param name="orderRefund"></param>
        public static void RefundToAnyPay(OrderRefundInfo orderRefund)
        {
            if (orderRefund.Status != (int)OrderRefundStatus.Returning)
            {
                return;
            }

            if (RefundOnline)
            {
                if (PayPlugins.ReadPayPlugins(orderRefund.RefundPayKey).IsOnline == 1 && (OrderBLL.Read(orderRefund.OrderId).AliPayTradeNo.Trim() != string.Empty || OrderBLL.Read(orderRefund.OrderId).WxPayTradeNo.Trim() != string.Empty))//只有在线付款才走线上流程,并且存在支付交易号(支付宝微信任意一个)
                {
                    //退款到各支付渠道
                    //如需退余额,将在第三方支付退款成功后操作
                    //这样做的好处在于保障了余额能够被准确退还。不会出现退了余额,但支付宝或微信因为人为或意外的原因没退成功的情况。
                    if (orderRefund.RefundMoney > 0)
                    {
                        //HttpContext.Current.Response.Redirect(string.Format("/Plugins/Pay/{0}/Refund.aspx?order_refund_id={1}", orderRefund.RefundPayKey, orderRefund.Id));
                        HttpContext.Current.Response.Redirect(string.Format("/Plugins/Pay/{0}/Refund.aspx?order_refund_id={1}&returnurl={2}", orderRefund.RefundPayKey, orderRefund.Id, RefundRedirectUrl));
                    }
                    else
                    {
                        //只需退款到余额
                        //在这里写自己的逻辑
                        if (orderRefund.RefundBalance > 0)
                        {
                            //HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}", orderRefund.Id));
                            HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}&returnurl={1}", orderRefund.Id, RefundRedirectUrl));
                        }
                    }
                }
                else//线下退款则直接更改状态,所以线下退款只能管理员自己审核。
                {
                    orderRefund.Remark   = "退款完成";
                    orderRefund.Status   = (int)OrderRefundStatus.HasReturn;
                    orderRefund.TmRefund = DateTime.Now;
                    OrderRefundBLL.Update(orderRefund);

                    OrderRefundActionBLL.Add(new OrderRefundActionInfo
                    {
                        OrderRefundId = orderRefund.Id,
                        Status        = 1,
                        Tm            = DateTime.Now,
                        UserType      = 2,
                        UserId        = Cookies.Admin.GetAdminID(false),
                        UserName      = Cookies.Admin.GetAdminName(false),
                        Remark        = orderRefund.Remark
                    });
                    #region 发送订单退款成功通知
                    int       isSendNotice  = ShopConfig.ReadConfigInfo().RefundOrder;
                    int       isSendEmail   = ShopConfig.ReadConfigInfo().RefundOrderEmail;
                    int       isSendMessage = ShopConfig.ReadConfigInfo().RefundOrderMsg;
                    string    key           = "RefundOrder";
                    OrderInfo order         = OrderBLL.Read(orderRefund.OrderId);
                    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 += "未发送通知短信。";
                        }
                    }
                    #endregion
                    if (string.IsNullOrEmpty(RefundRedirectUrl))
                    {
                        HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundAdd.aspx?id={0}", orderRefund.Id));
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(RefundRedirectUrl);
                    }
                }
            }
            else
            {
                //处理订单、商品的退款状态,线下退款
                //在这里写自己的逻辑
                HttpContext.Current.Response.Redirect(string.Format("/Admin/OrderRefundToBalance.aspx?order_refund_id={0}&returnurl={1}", orderRefund.Id, RefundRedirectUrl));
            }
        }
Beispiel #27
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();
        }
Beispiel #28
0
        /// <summary>
        /// 读取订单用户操作
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="checkStatus">订单状态</param>
        /// <param name="payKey">支付方式关键字</param>
        /// <returns></returns>
        public static string ReadOrderUserOperate(int orderId, int orderStatus, string payKey, int userId)
        {
            string    result = string.Empty;
            OrderInfo order  = OrderBLL.Read(orderId);

            if (order.IsDelete == (int)BoolType.False)
            {
                switch (orderStatus)
                {
                case (int)OrderStatus.WaitPay:
                    if (payKey == "WxPay")
                    {
                        if (RequestHelper.UserAgent() && RequestHelper.IsMicroMessenger())
                        {
                            result += " <a href=\"/Plugins/Pay/WxPay/Pay.aspx?order_id=" + orderId.ToString() + "\" target=\"_blank\" class=\"red\">付款</a>";
                        }
                        else
                        {
                            result += " <a href=\"/finish.html?ID=" + orderId.ToString() + "\" class=\"red\" target=\"_blank\">付款</a>";
                        }
                    }
                    else
                    {
                        if (PayPlugins.ReadPayPlugins(payKey).IsOnline == (int)BoolType.True)
                        {
                            result = " <a href=\"/Plugins/Pay/" + payKey + "/Pay.aspx?order_id=" + orderId.ToString() + "\" target=\"_blank\" class=\"red\">付款</a>";
                        }
                    }
                    result += "<a href=\"javascript:orderOperate(" + orderId + "," + (int)OrderOperate.Cancle + ")\" class=\"red\">取消</a>";
                    break;

                case (int)OrderStatus.WaitCheck:
                    if (PayPlugins.ReadPayPlugins(payKey).IsOnline != (int)BoolType.True)
                    {
                        result = "<a href=\"javascript:orderOperate(" + orderId + "," + (int)OrderOperate.Cancle + ")\"  class=\"red\">取消</a>";
                    }
                    break;

                case (int)OrderStatus.NoEffect:
                case (int)OrderStatus.Shipping:
                    break;

                case (int)OrderStatus.HasShipping:
                    result  = "<a href=\"/User/ShippingList.html?OrderID=" + orderId + "\" class=\"red\">查看物流</a>";
                    result += "   <a href=\"javascript:orderOperate(" + orderId + "," + (int)OrderOperate.Received + ")\" class=\"red\">确定收货</a>";
                    break;

                case (int)OrderStatus.ReceiveShipping:
                    //if (!ProductCommentBLL.HasCommented(orderId, userId))
                    //{
                    //    result = "<a href=\"/user/userproductcommentadd.html?orderid=" + orderId + "\" title=\"订单评价\" class=\"a1\">评价</a>";
                    //}
                    break;

                case (int)OrderStatus.HasReturn:
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
Beispiel #29
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");
        }
        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;
        }