Beispiel #1
0
        /// <summary>
        /// 结算页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Checkout()
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            if (ShoppingCartIsEmpty(shoppingCart))
            {
                return(Redirect(PageHelper.BuildUrl("ShoppingCart")));
            }

            var checkOutResult = ShoppingFacade.BuildCheckOut(null, shoppingCart, CurrUser.UserSysNo);

            //重新保存一次购物车cookie,在购物流程中会对购物车中库存数量不足的赠品进行剔除
            ShoppingCart pipelineShoppingCart = (checkOutResult.OrderProcessResult != null &&
                                                 checkOutResult.OrderProcessResult.ReturnData != null &&
                                                 checkOutResult.OrderProcessResult.ReturnData["ShoppingCart"] != null)
                ? checkOutResult.OrderProcessResult.ReturnData["ShoppingCart"] as ShoppingCart
                : ShoppingStorageManager.GetShoppingCartFromCookie();
            //Key添加CustomerSysNo
            LoginUser userInfo = UserManager.ReadUserInfo();

            shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
            ShoppingStorageManager.SaveShoppingCart(pipelineShoppingCart);

            return(View(checkOutResult));
        }
Beispiel #2
0
        /// <summary>
        /// 不经过购物车直接购买商品,不持久化到cookie中
        /// 多个商品编号用逗号(,)隔开,多个购买数量用逗号(,)隔开
        /// </summary>
        /// <param name="productSysNo">商品编号</param>
        /// <param name="quantity">商品数量</param>
        /// <returns></returns>
        public ActionResult DirectCheckout(string productSysNo, string quantity)
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromParam(productSysNo, quantity);

            if (ShoppingCartIsEmpty(shoppingCart))
            {
                return(Redirect(PageHelper.BuildUrl("ShoppingCart")));
            }

            var checkOutResult = ShoppingFacade.BuildCheckOut(null, shoppingCart, CurrUser.UserSysNo);

            checkOutResult.ShoppingItemParam = productSysNo + "|" + quantity;

            return(View("Checkout", checkOutResult));
        }
Beispiel #3
0
        /// <summary>
        /// 不经过购物车直接购买商品,不持久化到cookie中
        /// 多个商品编号用逗号(,)隔开,多个购买数量用逗号(,)隔开
        /// </summary>
        /// <param name="productSysNo">商品编号</param>
        /// <param name="quantity">商品数量</param>
        /// <returns></returns>
        public ActionResult DirectCheckout(string productSysNo, string quantity)
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromParam(productSysNo, quantity);

            if (ShoppingCartIsEmpty(shoppingCart))
            {
                throw new BusinessException("无效的请求");
            }
            var checkOutResult = ShoppingFacade.BuildCheckOut(null, shoppingCart, CurrUser.UserSysNo);

            checkOutResult.ShoppingItemParam = productSysNo + "|" + quantity;

            checkOutResult = CalcGroupBuyTag(checkOutResult);

            return(View("Checkout", checkOutResult));
        }
Beispiel #4
0
        private CheckOutResult BuildCheckout(CheckOutContext context)
        {
            if (context == null)
            {
                throw new BusinessException("无效的请求");
            }
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();

            //优先从购买商品参数来构建购物车对象
            if (!String.IsNullOrWhiteSpace(context.ShoppingItemParam))
            {
                String[] shoppingItemParams = context.ShoppingItemParam.Split(new char[] { '|' });
                if (shoppingItemParams.Length == 2)
                {
                    shoppingCart = ShoppingStorageManager.GetShoppingCartFromParam(shoppingItemParams[0], shoppingItemParams[1]);
                }
            }
            //其次从cookie中来构建购物车对象
            if (ShoppingCartIsEmpty(shoppingCart))
            {
                shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
            }

            var checkOutResult = ShoppingFacade.BuildCheckOut(context, shoppingCart, CurrUser.UserSysNo);

            //重新保存一次购物车cookie,在购物流程中会对购物车中库存数量不足的赠品进行剔除
            //fixbug: 直接购物车下单不应该影响购物车Cookie
            if (String.IsNullOrWhiteSpace(context.ShoppingItemParam))
            {
                ShoppingCart pipelineShoppingCart = (checkOutResult.OrderProcessResult != null &&
                                                     checkOutResult.OrderProcessResult.ReturnData != null &&
                                                     checkOutResult.OrderProcessResult.ReturnData["ShoppingCart"] != null)
                    ? checkOutResult.OrderProcessResult.ReturnData["ShoppingCart"] as ShoppingCart
                    : ShoppingStorageManager.GetShoppingCartFromCookie();

                //Key添加CustomerSysNo
                LoginUser userInfo = UserManager.ReadUserInfo();
                shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
                ShoppingStorageManager.SaveShoppingCart(pipelineShoppingCart);
            }

            return(checkOutResult);
        }
Beispiel #5
0
        public static CheckOutResultModel AjaxBuildCheckOut(CheckOutContext context)
        {
            if (context == null)
            {
                throw new BusinessException("无效的请求");
            }

            ShoppingCart shoppingCart    = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            ShoppingCart shoppingCartNew = ShoppingStorageManager.GetShoppingCartFromCreateNew();

            //优先从购买商品参数来构建购物车对象
            if (!String.IsNullOrWhiteSpace(context.ShoppingItemParam))
            {
                String[] shoppingItemParams = context.ShoppingItemParam.Split(new char[] { '|' });
                if (shoppingItemParams.Length == 2)
                {
                    shoppingCartNew = ShoppingStorageManager.GetShoppingCartFromParam(shoppingItemParams[0], shoppingItemParams[1]);
                }
            }
            //其次从cookie中来构建购物车对象
            if (ShoppingCartIsEmpty(shoppingCartNew))
            {
                shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
                ShoppingItemGroup ShoppingItem = new ShoppingItemGroup();
                shoppingCartNew.ShoppingItemGroupList = shoppingCart.ShoppingItemGroupList.FindAll(m => m.PackageChecked);
            }

            shoppingCartNew.OrderDeleteGiftSysNo = shoppingCart.OrderDeleteGiftSysNo;
            shoppingCartNew.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo;

            var checkOutResult        = ShoppingFacade.BuildCheckOut(context, shoppingCartNew, UserMgr.ReadUserInfo().UserSysNo);
            CheckOutResultModel model = OrderMapping.MappingCheckOutResult(checkOutResult);

            //重新保存一次购物车cookie,在购物流程中会对购物车中库存数量不足的赠品进行剔除
            //fixbug: 直接购物车下单不应该影响购物车Cookie
            if (String.IsNullOrWhiteSpace(context.ShoppingItemParam))
            {
                ShoppingStorageManager.SaveShoppingCart(GetShoppingCart(checkOutResult));
            }

            return(model);
        }
Beispiel #6
0
        /// <summary>
        /// 不经过购物车直接购买商品,不持久化到cookie中
        /// </summary>
        /// <param name="productSysNo">商品编号</param>
        /// <param name="quantity">商品数量</param>
        /// <returns></returns>
        public static CheckOutResultModel DirectCheckout(List <DirectCheckoutReqModel> list)
        {
            if (list == null)
            {
                throw new BusinessException("无效的请求");
            }

            //多个商品编号用逗号(,)隔开,多个购买数量用逗号(,)隔开
            StringBuilder productBuild  = new StringBuilder();
            StringBuilder quantityBuild = new StringBuilder();

            foreach (DirectCheckoutReqModel item in list)
            {
                productBuild.Append(item.ProductSysNo);
                productBuild.Append(",");
                quantityBuild.Append(item.Quantity);
                quantityBuild.Append(",");
            }

            string productSysNo = productBuild.ToString().TrimEnd(',');
            string quantity     = quantityBuild.ToString().TrimEnd(',');

            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromParam(productSysNo, quantity);

            if (ShoppingCartIsEmpty(shoppingCart))
            {
                throw new BusinessException("无效的请求");
            }

            var checkOutResult = ShoppingFacade.BuildCheckOut(null, shoppingCart, UserMgr.ReadUserInfo().UserSysNo);

            checkOutResult.ShoppingItemParam = productSysNo + "|" + quantity;

            CheckOutResultModel model = OrderMapping.MappingCheckOutResult(checkOutResult);

            return(model);
        }
Beispiel #7
0
        /// <summary>
        /// 普通商品checkout
        /// </summary>
        /// <returns></returns>
        public static CheckOutResultModel Checkout(string proSysNos = null, string packSysNos = null)
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            #region 得到新的shoppingCart
            ShoppingCart             shoppingCartNew = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            List <ShoppingItemGroup> ShoppingItem    = new List <ShoppingItemGroup>();
            //套餐
            ShoppingItem = shoppingCart.ShoppingItemGroupList.FindAll(m =>
                                                                      (m.PackageType.Equals(1) && m.PackageChecked));
            shoppingCartNew.ShoppingItemGroupList.AddRange(ShoppingItem);
            //单个商品
            ShoppingItem = shoppingCart.ShoppingItemGroupList.FindAll(m =>
                                                                      (m.PackageType.Equals(0) && m.ShoppingItemList[0].ProductChecked));
            shoppingCartNew.ShoppingItemGroupList.AddRange(ShoppingItem);
            #endregion
            if (ShoppingCartIsEmpty(shoppingCartNew))
            {
                throw new BusinessException("购物车不能为空");
            }
            shoppingCartNew.OrderDeleteGiftSysNo = shoppingCart.OrderDeleteGiftSysNo;
            shoppingCartNew.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo;

            LoginUser userInfo = UserMgr.ReadUserInfo();
            shoppingCartNew.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
            var checkOutResult = ShoppingFacade.BuildCheckOut(null, shoppingCartNew, userInfo.UserSysNo);

            checkOutResult.PackageTypeGroupList  = packSysNos;
            checkOutResult.PackageTypeSingleList = proSysNos;

            CheckOutResultModel model = OrderMapping.MappingCheckOutResult(checkOutResult);

            ShoppingStorageManager.SaveShoppingCart(GetShoppingCart(checkOutResult));

            return(model);
        }
Beispiel #8
0
        /// <summary>
        /// 普通商品checkout
        /// </summary>
        /// <returns></returns>
        public ActionResult Checkout()
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            #region 得到新的shoppingCart
            ShoppingCart      shoppingCartNew       = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            string            PackageTypeSingleList = Request.QueryString["PackageTypeSingle"];
            string            PackageTypeGroupList  = Request.QueryString["PackageTypeGroup"];
            ShoppingItemGroup ShoppingItem          = new ShoppingItemGroup();
            if (!string.IsNullOrEmpty(PackageTypeGroupList))
            {
                string[] array = PackageTypeGroupList.Split(',');
                foreach (var item in array)
                {
                    int sysNo = 0;
                    if (int.TryParse(item, out sysNo))
                    {
                        ShoppingItem = shoppingCart.ShoppingItemGroupList.FindAll(m =>
                                                                                  (m.PackageType.Equals(1) && m.PackageNo.Equals(sysNo)))[0];
                        shoppingCartNew.ShoppingItemGroupList.Add(ShoppingItem);
                    }
                }
            }

            if (!string.IsNullOrEmpty(PackageTypeSingleList))
            {
                string[] array = PackageTypeSingleList.Split(',');
                foreach (var item in array)
                {
                    int sysNo = 0;
                    if (int.TryParse(item, out sysNo))
                    {
                        ShoppingItem = shoppingCart.ShoppingItemGroupList.FindAll(m =>
                                                                                  (m.PackageType.Equals(0) && m.ShoppingItemList[0].ProductSysNo.Equals(sysNo)))[0];
                        shoppingCartNew.ShoppingItemGroupList.Add(ShoppingItem);
                    }
                }
            }
            #endregion
            if (ShoppingCartIsEmpty(shoppingCartNew))
            {
                return(Redirect(PageHelper.BuildUrl("ShoppingCartRoute")));
            }
            shoppingCartNew.OrderDeleteGiftSysNo = shoppingCart.OrderDeleteGiftSysNo;
            shoppingCartNew.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo;

            LoginUser userInfo = UserMgr.ReadUserInfo();
            shoppingCartNew.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
            var checkOutResult = ShoppingFacade.BuildCheckOut(null, shoppingCartNew, CurrUser.UserSysNo);
            checkOutResult.PackageTypeGroupList  = PackageTypeGroupList;
            checkOutResult.PackageTypeSingleList = PackageTypeSingleList;

            int bankAccountPoint = 0;
            bankAccountPoint = CookieHelper.GetCookie <int>("BankAccountPoint"); //获取网银用户积分
            checkOutResult.Customer.BankAccountPoint = bankAccountPoint;
            ViewBag.IsBankingAccount = bankAccountPoint > 0;                     //仅当网银积分>0方才显示该区域

            //重新保存一次购物车cookie,在购物流程中会对购物车中库存数量不足的赠品进行剔除
            ShoppingCart pipelineShoppingCart = (checkOutResult.OrderProcessResult != null &&
                                                 checkOutResult.OrderProcessResult.ReturnData != null &&
                                                 checkOutResult.OrderProcessResult.ReturnData["shoppingCartNew"] != null)
                ? checkOutResult.OrderProcessResult.ReturnData["shoppingCartNew"] as ShoppingCart
                : ShoppingStorageManager.GetShoppingCartFromCookie();

            ShoppingStorageManager.SaveShoppingCart(pipelineShoppingCart);

            checkOutResult = CalcGroupBuyTag(checkOutResult);

            return(View(checkOutResult));
        }
Beispiel #9
0
        public ActionResult AjaxBuildCheckOut(CheckOutContext context)
        {
            if (context == null)
            {
                throw new BusinessException("无效的请求");
            }

            ShoppingCart shoppingCart    = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            ShoppingCart shoppingCartNew = ShoppingStorageManager.GetShoppingCartFromCreateNew();

            //优先从购买商品参数来构建购物车对象
            if (!String.IsNullOrWhiteSpace(context.ShoppingItemParam))
            {
                String[] shoppingItemParams = context.ShoppingItemParam.Split(new char[] { '|' });
                if (shoppingItemParams.Length == 2)
                {
                    shoppingCartNew = ShoppingStorageManager.GetShoppingCartFromParam(shoppingItemParams[0], shoppingItemParams[1]);
                }
            }
            //其次从cookie中来构建购物车对象
            if (ShoppingCartIsEmpty(shoppingCartNew))
            {
                shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
                ShoppingItemGroup ShoppingItem = new ShoppingItemGroup();
                if (!string.IsNullOrEmpty(context.PackageTypeGroupList))
                {
                    string[] array = context.PackageTypeGroupList.Split(',');
                    foreach (var item in array)
                    {
                        int sysNo = 0;
                        if (int.TryParse(item, out sysNo))
                        {
                            ShoppingItem = shoppingCart.ShoppingItemGroupList.FindAll(m =>
                                                                                      (m.PackageType.Equals(1) && m.PackageNo.Equals(sysNo)))[0];
                            shoppingCartNew.ShoppingItemGroupList.Add(ShoppingItem);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(context.PackageTypeSingleList))
                {
                    string[] array = context.PackageTypeSingleList.Split(',');
                    foreach (var item in array)
                    {
                        int sysNo = 0;
                        if (int.TryParse(item, out sysNo))
                        {
                            ShoppingItem = shoppingCart.ShoppingItemGroupList.FindAll(m =>
                                                                                      (m.PackageType.Equals(0) && m.ShoppingItemList[0].ProductSysNo.Equals(sysNo)))[0];
                            shoppingCartNew.ShoppingItemGroupList.Add(ShoppingItem);
                        }
                    }
                }
            }

            shoppingCartNew.OrderDeleteGiftSysNo = shoppingCart.OrderDeleteGiftSysNo;
            shoppingCartNew.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo;

            var checkOutResult = ShoppingFacade.BuildCheckOut(context, shoppingCartNew, CurrUser.UserSysNo);

            //重新保存一次购物车cookie,在购物流程中会对购物车中库存数量不足的赠品进行剔除
            //fixbug: 直接购物车下单不应该影响购物车Cookie
            if (String.IsNullOrWhiteSpace(context.ShoppingItemParam))
            {
                ShoppingCart pipelineShoppingCart = (checkOutResult.OrderProcessResult != null &&
                                                     checkOutResult.OrderProcessResult.ReturnData != null &&
                                                     checkOutResult.OrderProcessResult.ReturnData["shoppingCartNew"] != null)
                    ? checkOutResult.OrderProcessResult.ReturnData["shoppingCartNew"] as ShoppingCart
                    : ShoppingStorageManager.GetShoppingCartFromCookie();


                //Key添加CustomerSysNo
                LoginUser userInfo = UserMgr.ReadUserInfo();
                pipelineShoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
                ShoppingStorageManager.SaveShoppingCart(pipelineShoppingCart);
            }

            checkOutResult = CalcGroupBuyTag(checkOutResult);

            return(PartialView("_CheckOutEditPanel", checkOutResult));
        }