public static AjaxResult AddToShoppingCart(UpdateCartReqModel req) { AjaxResult result = new AjaxResult(); result.Success = false; int totalProduct = 0; #region Check string checkResultMessage = ""; if (req.SysNo <= 0) { if (req.IsPackage) { checkResultMessage = "请输入正确的套餐编号!"; } else { checkResultMessage = "请输入正确的商品编号!"; } } else if (req.Qty <= 0) { checkResultMessage = "请输入正确的商品数量"; } #endregion #region 加入购物车 if (string.IsNullOrWhiteSpace(checkResultMessage)) { result.Success = true; checkResultMessage = "加入购物车失败"; ShoppingItemGroup shoppingItemGroup = ShoppingFacade.BuildShoppingItemGroup(req.IsPackage ? "package" : "product", req.SysNo, req.Qty); ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); if (shoppingItemGroup != null) { ShoppingFacade.AddToShoppingCart(shoppingItemGroup, shoppingCart); ShoppingStorageManager.SaveShoppingCart(shoppingCart); checkResultMessage = "加入购物车成功"; } //计算购物商品数量 if (shoppingCart != null && shoppingCart.ShoppingItemGroupList != null) { foreach (var itemGroup in shoppingCart.ShoppingItemGroupList) { foreach (var item in itemGroup.ShoppingItemList) { totalProduct += itemGroup.Quantity * item.UnitQuantity; } } } } result.Data = totalProduct; result.Message = checkResultMessage; #endregion return(result); }
/// <summary> /// 选择加够商品 /// </summary> /// <param name="productSysNoList">商品编号列表</param> /// <returns></returns> public static CartResultModel SltPlusBuyProduct(List <int> productSysNoList, string proSysNos = null, string packSysNos = null) { #region Check string checkResultMessage = ""; if (productSysNoList == null || productSysNoList.Count <= 0) { checkResultMessage = "请选择加够商品!"; } #endregion #region 择加够商品 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); //此处于KJT逻辑不通,保留了TL的逻辑,如果有问题,请修改 if (string.IsNullOrWhiteSpace(checkResultMessage)) { if (shoppingCart.PlusPriceProductSelectList == null) { shoppingCart.PlusPriceProductSelectList = new List <int>(); } foreach (int sysNo in productSysNoList) { if (!shoppingCart.PlusPriceProductSelectList.Exists(m => m == sysNo)) { shoppingCart.PlusPriceProductSelectList.Add(sysNo); } } } #endregion return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); }
/// <summary> /// 删除购物车中订单上某活动选择的某赠品 /// </summary> /// <param name="req"></param> /// <returns></returns> public static CartResultModel DelOrderSltGift(OrderGiftReqModel req, string proSysNos = null, string packSysNos = null) { #region Check string checkResultMessage = ""; if (req.ActivityNo <= 0) { checkResultMessage = "请输入正确的活动编号!"; } else if (req.GiftSysNo <= 0) { checkResultMessage = "请输入正确的赠品编号!"; } #endregion #region 除订单上某活动选择的赠品 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); if (string.IsNullOrWhiteSpace(checkResultMessage)) { //删除订单上某活动选择的赠品 if (shoppingCart.OrderSelectGiftSysNo == null) { shoppingCart.OrderSelectGiftSysNo = new List <ShoppingOrderGift>(); } shoppingCart.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo.FindAll(m => m.ActivityNo != req.ActivityNo || m.GiftSysNo != req.GiftSysNo); } #endregion return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); }
/// <summary> /// 删除套餐 /// </summary> /// <param name="packageSysNo"></param> /// <returns></returns> private static CartResultModel DelPackage(int packageSysNo, string proSysNos = null, string packSysNos = null) { #region Check string checkResultMessage = ""; if (packageSysNo <= 0) { checkResultMessage = "请输入正确的套餐编号!"; } #endregion #region 除套餐商品 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); if (string.IsNullOrWhiteSpace(checkResultMessage)) { //删除套餐 shoppingCart.ShoppingItemGroupList = shoppingCart.ShoppingItemGroupList.FindAll(m => (m.PackageType.Equals(1) && !m.PackageNo.Equals(packageSysNo)) || m.PackageType.Equals(0)); } #endregion return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); }
/// <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)); }
/// <summary> /// 删除购物车中指定的商品 /// </summary> /// <param name="productSysNo"></param> /// <returns></returns> private static CartResultModel DelProduct(int productSysNo, string proSysNos = null, string packSysNos = null) { #region Check string checkResultMessage = ""; if (productSysNo <= 0) { checkResultMessage = "请输入正确的商品编号!"; } #endregion #region 除商品 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); shoppingCart.ShoppingItemGroupList = shoppingCart.ShoppingItemGroupList.FindAll(m => (m.PackageType.Equals(0) && !m.ShoppingItemList[0].ProductSysNo.Equals(productSysNo)) || m.PackageType.Equals(1)); #endregion return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); }
/// <summary> /// 获取购物车 /// </summary> /// <returns></returns> public static CartResultModel GetCart(string proSysNos = null, string packSysNos = null) { ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); string checkResultMessage = ""; return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); }
/// <summary> /// 修改套餐数量 /// </summary> /// <param name="packageSysNo"></param> /// <param name="qty"></param> /// <returns></returns> private static CartResultModel UpdatePackage(int packageSysNo, int qty, string proSysNos = null, string packSysNos = null) { #region Check string checkResultMessage = ""; if (packageSysNo <= 0) { checkResultMessage = "请输入正确的套餐编号!"; } else if (qty <= 0) { checkResultMessage = "请输入正确的商品数量"; } #endregion #region 更改数量 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); if (string.IsNullOrWhiteSpace(checkResultMessage)) { //更改数量 shoppingCart.ShoppingItemGroupList.ForEach(item => { if (item.PackageType.Equals(1) && item.PackageNo.Equals(packageSysNo)) { item.Quantity = qty; } }); } return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); #endregion }
public ActionResult AjaxGetShipTypeList(string paymentcateid, string shipaddrsysno) { PaymentCategory paymentCate; int shipAddrSysNo; if (!Enum.TryParse(paymentcateid, out paymentCate)) { throw new BusinessException("无效的请求"); } if (!int.TryParse(shipaddrsysno, out shipAddrSysNo)) { throw new BusinessException("无效的请求"); } var shippingAddress = CustomerShippingAddresssFacade.GetCustomerShippingAddress(shipAddrSysNo, CurrUser.UserSysNo); if (shippingAddress == null) { return(PartialView("_ShipTypePanel", new List <ShipTypeInfo>(0))); } ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); CheckOutResult result = ShoppingFacade.GetPayAndShipTypeList(null, CurrUser.UserSysNo, shoppingCart); var shipTypeList = result.ShipTypeList; //var shipTypeList = ShipTypeFacade.GetSupportedShipTypeList(shippingAddress.ReceiveAreaSysNo, paymentCate); return(PartialView("_ShipTypePanel", shipTypeList)); }
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)); }
/// <summary> /// 选择购物车中订单上某活动的某赠品 /// </summary> /// <param name="req"></param> /// <returns></returns> public static CartResultModel SltOrderGift(SltOrderGiftReqModel req, string proSysNos = null, string packSysNos = null) { #region Check string checkResultMessage = ""; if (req.ActivityNo <= 0) { checkResultMessage = "请输入正确的活动编号!"; } else if (req.GiftSysNos == null || req.GiftSysNos.Count <= 0) { checkResultMessage = "请输入正确的赠品编号!"; } #endregion #region 择订单上某活动的赠品 ShoppingCart shoppingCart = ShoppingStorageManager.GetShoppingCartFromCookieOrCreateNew(); if (string.IsNullOrWhiteSpace(checkResultMessage)) { //选择订单上某活动的赠品 if (shoppingCart.OrderSelectGiftSysNo == null) { shoppingCart.OrderSelectGiftSysNo = new List <ShoppingOrderGift>(); } //剔除当前活动已选择的赠品 shoppingCart.OrderSelectGiftSysNo = shoppingCart.OrderSelectGiftSysNo.FindAll(m => !m.ActivityNo.Equals(req.ActivityNo)); foreach (int sysNo in req.GiftSysNos) { shoppingCart.OrderSelectGiftSysNo.Add(new ShoppingOrderGift() { ActivityNo = req.ActivityNo, GiftSysNo = sysNo }); } } #endregion return(BuilderOrderResultModel(shoppingCart, checkResultMessage, proSysNos, packSysNos)); }