예제 #1
0
        //
        // GET: /Web/Home/
        public ActionResult Logout()
        {
            UserMgr.Logout();
            string url = PageHelper.BuildUrl("Web_Index");

            return(Redirect(url));
        }
예제 #2
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));
        }
예제 #3
0
        /// <summary>
        /// 构造二级域名的Url(开发人员请根据项目需求,确定该处是否该使用本方法)。
        /// </summary>
        /// <param name="sellerSysNo"></param>
        /// <param name="pageSysNo"></param>
        /// <returns></returns>
        public static string BuildStoreUrl(int sellerSysNo, int?pageSysNo)
        {
            List <StoreDomainPage> list      = StoreFacade.GetAllStoreDomainHomePageList();
            StoreDomainPage        storePage = list.Find(f => f.SellerSysNo == sellerSysNo);

            string webDomain = ConstValue.WebDomain.TrimEnd("/".ToCharArray());
            string url       = "#";

            if (storePage == null)
            {
                url = PageHelper.BuildUrl("StorePage", sellerSysNo, pageSysNo, false);
            }
            else
            {
                Uri    uri      = HttpContext.Current.Request.Url;
                string portName = uri.Port == 80 ? "" : ":" + uri.Port.ToString();

                string domainOnlyHost = ConstValue.WebDomainOnlyHost.Trim();

                url = "http://" + storePage.SecondDomain + "." + domainOnlyHost + portName + "/store/" + storePage.SellerSysNo.ToString() + "/" + storePage.HomePageSysNo.ToString();
            }


            return(url);
        }
예제 #4
0
        //
        // GET: /Web/Customer/
        public ActionResult Login()
        {
            if (!string.IsNullOrEmpty(Request["returnurl"]))
            {
                ViewBag.ReturnUrl = Request["returnurl"];
            }
            else
            {
                ViewBag.ReturnUrl = PageHelper.BuildUrl("Web_Index");
            }

            return(View());
        }
예제 #5
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));
        }
예제 #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
        /// <summary>
        /// 加入购物车
        /// </summary>
        /// <note>
        /// Request Param:
        /// Category-加入的对象类型;Product-商品,Package-套餐
        /// SysNo-根据加入的对象类型对应的系统编号
        /// Qty-数量
        /// e.g:?Category=Package&SysNo=1006&Qty=2
        /// </note>
        /// <returns></returns>
        public ActionResult AddToShoppingCart()
        {
            string shoppingCartUrl = PageHelper.BuildUrl("ShoppingCartRoute");

            #region 1.Check
            int    sysNo    = 0;
            int    qty      = 0;
            string category = Request.Params["Category"];
            if (string.IsNullOrWhiteSpace(category) || (category.Equals("Product") && category.Equals("Package")))
            {
                return(Redirect(shoppingCartUrl));
            }
            else if (!int.TryParse(Request.Params["SysNo"], out sysNo) || sysNo <= 0)
            {
                return(Redirect(shoppingCartUrl));
            }
            else if (!int.TryParse(Request.Params["Qty"], out qty) || qty <= 0)
            {
                return(Redirect(shoppingCartUrl));
            }
            if (category.Equals("Product"))
            {
                var product = ProductFacade.GetProductBasicInfoBySysNo(sysNo);
                if (product == null || product.ProductStatus != Enums.ProductStatus.Show)
                {
                    return(Redirect(shoppingCartUrl));
                }
            }
            #endregion

            #region 2.加入购物车
            ShoppingItemGroup shoppingItemGroup = ShoppingFacade.BuildShoppingItemGroup(category, sysNo, qty);
            ShoppingCart      shoppingCart      = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew();
            if (shoppingItemGroup != null)
            {
                //用于计算会员价:
                LoginUser userInfo = UserMgr.ReadUserInfo();
                shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;

                ShoppingFacade.AddToShoppingCart(shoppingItemGroup, shoppingCart);
                ShoppingStorageManager.SaveShoppingCart(shoppingCart);
            }
            #endregion

            return(Redirect(shoppingCartUrl));
        }
예제 #8
0
        public static MvcHtmlString BuildCrumb(List <CrumbItem> itemList)
        {
            StringBuilder sb = new StringBuilder();

            if (itemList != null && itemList.Count > 0)
            {
                sb.Append("<div class=\"crumb\">");
                sb.Append("<a href=\"" + PageHelper.BuildUrl("Web_Index") + "\">" + LanguageHelper.GetText("首页") + "</a>");
                int i = 1;
                foreach (CrumbItem item in itemList)
                {
                    if (i < itemList.Count)
                    {
                        sb.Append("<b>></b>");
                        if (string.IsNullOrWhiteSpace(item.ItemUrl))
                        {
                            sb.Append(string.Format("{0}", item.ItemName));
                        }
                        else
                        {
                            sb.Append(string.Format("<a href=\"{0}\">{1}</a>", item.ItemUrl, item.ItemName));
                        }
                    }
                    else
                    {
                        sb.Append("<b>></b>");
                        sb.Append(string.Format("<strong>{0}</strong>", item.ItemName));
                    }

                    i++;
                }
                sb.Append("</div>");
            }

            return(new MvcHtmlString(sb.ToString()));
        }
예제 #9
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));
        }
예제 #10
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 }));
        }