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