示例#1
0
        /// <summary>
        /// 加载购物车信息
        /// </summary>
        /// <returns>购物车信息</returns>
        private PartialViewResult LoadShoppingCartData(ShoppingCart shoppingCart, string errorMessage = "")
        {
            //Key添加CustomerSysNo
            LoginUser userInfo = UserManager.ReadUserInfo();

            shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
            OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart);
            ShoppingCart pipelineShoppingCart         = (shoppingResult.ReturnData != null &&
                                                         shoppingResult.ReturnData["ShoppingCart"] != null)
                ? shoppingResult.ReturnData["ShoppingCart"] as ShoppingCart
                : ShoppingStorageManager.GetShoppingCartFromCreateNew();

            shoppingCart.OrderSelectGiftSysNo = pipelineShoppingCart.OrderSelectGiftSysNo;
            shoppingCart.OrderDeleteGiftSysNo = pipelineShoppingCart.OrderDeleteGiftSysNo;
            ShoppingStorageManager.SaveShoppingCart(shoppingCart);

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                //更改失败返回错误信息
                if (shoppingResult.ErrorMessages != null)
                {
                    shoppingResult.ErrorMessages = new List <string>()
                    {
                        errorMessage
                    };
                }
                else
                {
                    shoppingResult.ErrorMessages.Add(errorMessage);
                }
            }

            return(PartialView("_ShoppingCartPanel", shoppingResult));
        }
示例#2
0
        /// <summary>
        /// 删除购物车中指定套餐中的某商品
        /// </summary>
        /// <note>Request Param:
        /// PackageSysNo-套餐编号
        /// ProductSysNo-商品编号
        /// </note>
        /// <returns></returns>
        public PartialViewResult DelPackageProduct()
        {
            #region 1.Check
            string checkResultMessage = "";
            int    packageSysNo       = 0;
            int    productSysNo       = 0;
            if (!int.TryParse(Request.Params["PackageSysNo"], out packageSysNo))
            {
                checkResultMessage = "请输入正确的套餐编号!";
            }
            else if (!int.TryParse(Request.Params["ProductSysNo"], out productSysNo))
            {
                checkResultMessage = "请输入正确的商品编号!";
            }
            string PackageTypeSingleList = Request.QueryString["PackageTypeSingle"];
            string PackageTypeGroupList  = Request.QueryString["PackageTypeGroup"];
            #endregion

            #region 2.删除套餐中的商品
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            ShoppingCart newShoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            if (string.IsNullOrWhiteSpace(checkResultMessage))
            {
                //删除套餐中的商品
                newShoppingCart = DelPackageProductCalcShoppingCart(shoppingCart, packageSysNo, productSysNo);
            }
            //用于计算会员价:
            LoginUser userInfo = UserMgr.ReadUserInfo();
            newShoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
            #endregion

            return(LoadShoppingCartData(newShoppingCart, checkResultMessage, PackageTypeSingleList, PackageTypeGroupList));
        }
示例#3
0
        /// <summary>
        /// 删除购物车中指定套餐中的某商品
        /// </summary>
        /// <note>Request Param:
        /// PackageSysNo-套餐编号
        /// ProductSysNo-商品编号
        /// </note>
        /// <returns></returns>
        private static CartResultModel DelPackageProduct(int packageSysNo, int productSysNo, string proSysNos = null, string packSysNos = null)
        {
            #region 1.Check
            string checkResultMessage = "";
            if (packageSysNo <= 0)
            {
                checkResultMessage = "请输入正确的套餐编号!";
            }
            else if (productSysNo <= 0)
            {
                checkResultMessage = "请输入正确的商品编号!";
            }
            #endregion

            #region 2.删除套餐中的商品
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            ShoppingCart newShoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            if (string.IsNullOrWhiteSpace(checkResultMessage))
            {
                //删除套餐中的商品
                newShoppingCart = DelPackageProductCalcShoppingCart(shoppingCart, packageSysNo, productSysNo);
            }
            #endregion

            return(BuilderOrderResultModel(newShoppingCart, checkResultMessage, proSysNos, packSysNos));
        }
示例#4
0
        /// <summary>
        /// 删除购物车中指定套餐中的某商品
        /// </summary>
        /// <note>Request Param:
        /// PackageSysNo-套餐编号
        /// ProductSysNo-商品编号
        /// </note>
        /// <returns></returns>
        public PartialViewResult DelPackageProduct()
        {
            #region 1.Check
            string checkResultMessage = "";
            int    packageSysNo       = 0;
            int    productSysNo       = 0;
            if (!int.TryParse(Request.Params["PackageSysNo"], out packageSysNo))
            {
                checkResultMessage = "请输入正确的套餐编号!";
            }
            else if (!int.TryParse(Request.Params["ProductSysNo"], out productSysNo))
            {
                checkResultMessage = "请输入正确的商品编号!";
            }
            #endregion

            #region 2.删除套餐中的商品
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();

            ShoppingCart newShoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            if (string.IsNullOrWhiteSpace(checkResultMessage))
            {
                //删除套餐中的商品
                newShoppingCart = DelPackageProductCalcShoppingCart(shoppingCart, packageSysNo, productSysNo);
            }
            #endregion

            return(LoadShoppingCartData(newShoppingCart, checkResultMessage));
        }
示例#5
0
        /// <summary>
        /// 删除套餐中的商品
        /// </summary>
        /// <param name="shoppingCart">购物车Cookie</param>
        /// <param name="packageSysNo">套餐编号</param>
        /// <param name="productSysNo">商品编号</param>
        /// <returns></returns>
        private ShoppingCart DelPackageProductCalcShoppingCart(ShoppingCart shoppingCart, int packageSysNo, int productSysNo)
        {
            ShoppingCart      newShoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();
            ShoppingItemGroup delItem         = new ShoppingItemGroup();

            shoppingCart.ShoppingItemGroupList.ForEach(item =>
            {
                if (item.PackageType.Equals(1) && item.PackageNo.Equals(packageSysNo))
                {
                    delItem = item;
                }
                else
                {
                    newShoppingCart.ShoppingItemGroupList.Add(item);
                }
            });
            //已合并的商品列表
            List <int> mergeProductList = new List <int>();

            //删除该套餐中的指定商品
            delItem.ShoppingItemList = delItem.ShoppingItemList.FindAll(m => !m.ProductSysNo.Equals(productSysNo));
            //检查是否需要合并
            newShoppingCart.ShoppingItemGroupList.ForEach(item =>
            {
                //只有单个商品才合并,套餐中的该商品不合并在一起
                if (item.PackageType.Equals(0))
                {
                    delItem.ShoppingItemList.ForEach(m =>
                    {
                        if (item.ShoppingItemList[0].ProductSysNo.Equals(m.ProductSysNo))
                        {
                            item.Quantity += delItem.Quantity * m.UnitQuantity;
                            mergeProductList.Add(m.ProductSysNo);
                        }
                    });
                }
            });
            delItem.ShoppingItemList.ForEach(m =>
            {
                if (!mergeProductList.Exists(x => x.Equals(m.ProductSysNo)))
                {
                    //该商品未被合并,需要单独新加一个商品
                    ShoppingItemGroup needSingleAddItemGroup = new ShoppingItemGroup()
                    {
                        PackageType      = 0,
                        PackageNo        = 0,
                        Quantity         = delItem.Quantity,
                        ShoppingItemList = delItem.ShoppingItemList.FindAll(y => y.ProductSysNo.Equals(m.ProductSysNo))
                    };
                    needSingleAddItemGroup.Quantity = needSingleAddItemGroup.Quantity * needSingleAddItemGroup.ShoppingItemList[0].UnitQuantity;
                    needSingleAddItemGroup.ShoppingItemList[0].UnitQuantity = 1;

                    newShoppingCart.ShoppingItemGroupList.Add(needSingleAddItemGroup);
                }
            });
            return(newShoppingCart);
        }
示例#6
0
        public JsonResult AjaxSubmitCheckout(CheckOutContext context)
        {
            if (context == null)
            {
                return(Json(BuildAjaxErrorObject("无效的请求")));
            }

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

            if (ShoppingCartIsEmpty(shoppingCart))
            {
                return(Json(new { url = PageHelper.BuildUrl("ShoppingCart") }));
            }

            CheckOutResult result = ShoppingFacade.SubmitCheckout(context, shoppingCart, CurrUser.UserSysNo, SOSource.Wechat);

            if (result.HasSucceed)
            {
                //取得订单编号列表
                List <int> soSysNoList = result.OrderProcessResult.ReturnData.SubOrderList.Select(subOrder => subOrder.Value.ID).ToList();
                ShoppingStorageManager.SaveLatestSO(soSysNoList);
                //团购订单数据不是来自cookie,不能清除cookie
                if (!result.OrderProcessResult.ReturnData.SubOrderList.Any(x => x.Value.SOType == (int)SOType.GroupBuy))
                {
                    ShoppingStorageManager.RemoveShoppingCartCookie();
                }
                return(Json(new { url = PageHelper.BuildUrl("Thankyou", result.OrderProcessResult.ReturnData.ShoppingCartID) }));
            }

            return(Json(new { error = true, messages = result.ErrorMessages }));
        }
示例#7
0
        public ActionResult AjaxGetPayAndShipType(CheckOutContext context)
        {
            ShoppingCart shoppingCart    = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
            ShoppingCart shoppingCartNew = ShoppingStorageManager.GetShoppingCartFromCreateNew();

            if (context == null)
            {
                throw new BusinessException("无效的请求");
            }
            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);
                    }
                }
            }
            CheckOutResult result = ShoppingFacade.GetPayAndShipTypeList(context, CurrUser.UserSysNo, shoppingCartNew);

            return(PartialView("_PayAndShipTypePanel", result));
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
0
        //
        // GET: /Shopping/

        public ActionResult Index()
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
            OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart);
            ShoppingCart pipelineShoppingCart         = (shoppingResult.ReturnData != null &&
                                                         shoppingResult.ReturnData["ShoppingCart"] != null)
                ? shoppingResult.ReturnData["ShoppingCart"] as ShoppingCart
                : ShoppingStorageManager.GetShoppingCartFromCreateNew();

            shoppingCart.OrderSelectGiftSysNo = pipelineShoppingCart.OrderSelectGiftSysNo;
            shoppingCart.OrderDeleteGiftSysNo = pipelineShoppingCart.OrderDeleteGiftSysNo;

            //Key添加CustomerSysNo
            LoginUser userInfo = UserManager.ReadUserInfo();

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

            return(View(shoppingResult));
        }
示例#11
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);
        }
示例#12
0
        /// <summary>
        /// 清空购物车
        /// <note>Request Param:N/A</note>
        /// </summary>
        /// <returns></returns>
        public PartialViewResult ClearAll()
        {
            ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();

            return(LoadShoppingCartData(shoppingCart));
        }
示例#13
0
        public static AjaxResult AjaxSubmitCheckout(CheckOutContext context)
        {
            AjaxResult ajaxResult = new AjaxResult();

            ajaxResult.Success = false;
            ajaxResult.Code    = -1;
            if (context == null)
            {
                ajaxResult.Code    = -2;
                ajaxResult.Message = "无效的请求";

                return(ajaxResult);
            }

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

            if (ShoppingCartIsEmpty(shoppingCartNew))
            {
                ajaxResult.Code    = -3;
                ajaxResult.Message = "空购物车";

                return(ajaxResult);
            }
            shoppingCartNew.OrderDeleteGiftSysNo = shoppingCart.OrderDeleteGiftSysNo;
            shoppingCartNew.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo;
            CheckOutResult result = ShoppingFacade.SubmitCheckout(context, shoppingCartNew, UserMgr.ReadUserInfo().UserSysNo, HeaderHelper.GetClientType() == ClientType.IPhone ? SOSource.IPhone : SOSource.Android);

            if (result.ErrorMessages != null && result.ErrorMessages.Count > 0)
            {
                result.ErrorMessages.ForEach(item =>
                {
                    if (!string.IsNullOrWhiteSpace(item))
                    {
                        ajaxResult.Message += item;
                    }
                });
            }
            if (result.HasSucceed)
            {
                //取得订单编号列表
                List <int> soSysNoList = result.OrderProcessResult.ReturnData.SubOrderList.Select(subOrder => subOrder.Value.ID).ToList();
                ShoppingStorageManager.SaveLatestSO(soSysNoList);
                //团购订单数据不是来自cookie,不能清除cookie
                if (!result.OrderProcessResult.ReturnData.SubOrderList.Any(x => x.Value.SOType == (int)SOType.GroupBuy))
                {
                    //ShoppingStorageManager.RemoveShoppingCartCookie();
                    ShoppingCart leaveshoppingCart = ShoppingStorageManager.GetShoppingCartFromCreateNew();
                    leaveshoppingCart.ShoppingItemGroupList = shoppingCart.ShoppingItemGroupList.FindAll(m => !m.PackageChecked);
                    if (leaveshoppingCart.ShoppingItemGroupList.Count > 0)
                    {
                        foreach (var itemGroup in leaveshoppingCart.ShoppingItemGroupList)
                        {
                            if (itemGroup.PackageType.Equals(0))
                            {
                                foreach (ShoppingItem ProductItem in itemGroup.ShoppingItemList)
                                {
                                    itemGroup.PackageChecked   = true;
                                    ProductItem.ProductChecked = true;
                                }
                            }
                            if (itemGroup.PackageType.Equals(1))
                            {
                                itemGroup.PackageChecked = true;
                            }
                        }
                    }
                    LoginUser userInfo = UserMgr.ReadUserInfo();
                    leaveshoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
                    HttpContext.Current.Request.Cookies.Remove(ShoppingStorageManager.GetConfigCartName());
                    ShoppingStorageManager.SaveShoppingCart(leaveshoppingCart);
                }

                ajaxResult.Code    = 0;
                ajaxResult.Success = true;
                ajaxResult.Data    = result.OrderProcessResult.ReturnData.ShoppingCartID;
                //var cookie = HttpContext.Current.Request.Cookies.Get(ShoppingStorageManager.GetConfigCartName());
                //ShoppingCart shoppingCart222 = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
                return(ajaxResult);
            }


            return(ajaxResult);
        }
示例#14
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));
        }
示例#15
0
        public JsonResult AjaxSubmitCheckout(CheckOutContext context)
        {
            if (context == null)
            {
                return(Json(BuildAjaxErrorObject("无效的请求")));
            }

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

            if (ShoppingCartIsEmpty(shoppingCartNew))
            {
                return(Json(new { url = PageHelper.BuildUrl("ShoppingCartRoute") }));
            }
            shoppingCartNew.OrderDeleteGiftSysNo = shoppingCart.OrderDeleteGiftSysNo;
            shoppingCartNew.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo;
            CheckOutResult result = ShoppingFacade.SubmitCheckout(context, shoppingCartNew, CurrUser.UserSysNo, SOSource.None);

            if (result.HasSucceed)
            {
                //取得订单编号列表
                List <int> soSysNoList = result.OrderProcessResult.ReturnData.SubOrderList.Select(subOrder => subOrder.Value.ID).ToList();
                ShoppingStorageManager.SaveLatestSO(soSysNoList);
                //团购订单数据不是来自cookie,不能清除cookie
                if (!result.OrderProcessResult.ReturnData.SubOrderList.Any(x => x.Value.SOType == (int)SOType.GroupBuy || x.Value.SOType == (int)SOType.VirualGroupBuy))
                {
                    //ShoppingStorageManager.RemoveShoppingCartCookie();
                    //移除mini购物车
                    //ShoppingStorageManager.RemoveShoppingCartMiniCookie();

                    //删除套餐
                    if (!string.IsNullOrEmpty(context.PackageTypeGroupList))
                    {
                        string[] array = context.PackageTypeGroupList.Split(',');
                        foreach (var item in array)
                        {
                            int sysNo = 0;
                            if (int.TryParse(item, out sysNo))
                            {
                                shoppingCart.ShoppingItemGroupList =
                                    shoppingCart.ShoppingItemGroupList.FindAll(m
                                                                               => (m.PackageType.Equals(1) && !m.PackageNo.Equals(sysNo)) ||
                                                                               m.PackageType.Equals(0));
                            }
                        }
                    }
                    //删除单个商品
                    if (!string.IsNullOrEmpty(context.PackageTypeSingleList))
                    {
                        string[] array = context.PackageTypeSingleList.Split(',');
                        foreach (var item in array)
                        {
                            int sysNo = 0;
                            if (int.TryParse(item, out sysNo))
                            {
                                shoppingCart.ShoppingItemGroupList =
                                    shoppingCart.ShoppingItemGroupList.FindAll(m
                                                                               => (m.PackageType.Equals(0) && !m.ShoppingItemList[0].ProductSysNo.Equals(sysNo)) ||
                                                                               m.PackageType.Equals(1));
                            }
                        }
                    }
                    //用于计算会员价:
                    LoginUser userInfo = UserMgr.ReadUserInfo();
                    shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
                    OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart);
                    ShoppingCart pipelineShoppingCart         = (shoppingResult.ReturnData != null &&
                                                                 shoppingResult.ReturnData["ShoppingCart"] != null)
                        ? shoppingResult.ReturnData["ShoppingCart"] as ShoppingCart
                        : new ShoppingCart();
                    shoppingCart.OrderSelectGiftSysNo = pipelineShoppingCart.OrderSelectGiftSysNo;
                    shoppingCart.OrderDeleteGiftSysNo = pipelineShoppingCart.OrderDeleteGiftSysNo;
                    ShoppingStorageManager.SaveShoppingCart(shoppingCart);
                    //将迷你购物车加入Cookie
                    ShoppingStorageManager.SaveShoppingCartMini(ShoppingFacade.BuildMiniShoppingCartFromPipeline(shoppingResult));
                }

                return(Json(new { url = PageHelper.BuildUrl("Thankyou", result.OrderProcessResult.ReturnData.ShoppingCartID) }));
            }

            return(Json(new { errors = result.ErrorMessages }));
        }
示例#16
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));
        }