public ActionResult Index(int page = 1, int pageSize = 5) { var dao = new PromotionDao(); var model = dao.ListAllPaging(page, pageSize); return(View(model)); }
public static Dictionary <int, List <StoreActivityEntity> > GetStoreActivityEntity(string storeIds, int gradeId) { if (string.IsNullOrEmpty(storeIds)) { return(new Dictionary <int, List <StoreActivityEntity> >()); } if (storeIds.EndsWith(",")) { storeIds = storeIds.Remove(storeIds.LastIndexOf(',')); } List <StoreActivityEntity> storeActivityEntity = new PromotionDao().GetStoreActivityEntity(storeIds, gradeId); return((from t in storeActivityEntity group t by new { t.StoreId, t.ActivityId } into lg select new StoreActivityEntity { StoreId = lg.Key.StoreId, ActivityId = lg.Key.ActivityId, ActivityName = lg.FirstOrDefault().ActivityName, PromoteType = lg.FirstOrDefault().PromoteType, StartDate = lg.FirstOrDefault().StartDate } into t2 group t2 by t2.StoreId).ToDictionary((IGrouping <int, StoreActivityEntity> t) => t.Key, (IGrouping <int, StoreActivityEntity> t) => t.ToList())); }
/// <summary> /// 获取用户连续签到天数 /// </summary> public static int GetContinuitySignCounts(int userId) { DataTable signDays = new PromotionDao().GetAllSignTime(userId); IList <DateTime> signDaysList = new List <DateTime>(); //首先要加上今天的时间 bool isTodaySigned = new PromotionDao().IsTodaySigned(userId); if (!isTodaySigned) { signDaysList.Add(DateTime.Now); } foreach (DataRow row in signDays.Rows) { signDaysList.Add(Convert.ToDateTime(row["SignTime"].ToString())); } int count = 0; for (int i = 0; i < signDaysList.Count - 1; i++) { TimeSpan ts = Convert.ToDateTime(signDaysList[i].ToString("yyyy-MM-dd")) - Convert.ToDateTime(signDaysList[i + 1].ToString("yyyy-MM-dd")); if (ts.Days == 1) { count++; } else { break; } } if (isTodaySigned) { count = count + 1; } return(count); }
public static ShoppingCartInfo GetShoppingCart(Member member, string productSkuId, int buyAmount, int storeId) { ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo(); //Member member = HiContext.Current.User as Member; ShoppingCartItemInfo cartItemInfo = new ShoppingCartDao().GetCartItemInfo(member, productSkuId, buyAmount, storeId); ShoppingCartInfo result; if (cartItemInfo == null) { result = null; } else { shoppingCartInfo.LineItems.Add(cartItemInfo); if (member != null) { decimal reducedPromotionAmount = 0m; PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(member, shoppingCartInfo.GetAmount(), shoppingCartInfo.GetQuantity(), out reducedPromotionAmount); if (reducedPromotion != null) { shoppingCartInfo.ReducedPromotionId = reducedPromotion.ActivityId; shoppingCartInfo.ReducedPromotionName = reducedPromotion.Name; shoppingCartInfo.ReducedPromotionAmount = reducedPromotionAmount; shoppingCartInfo.IsReduced = true; } PromotionInfo sendPromotion = new PromotionDao().GetSendPromotion(member, shoppingCartInfo.GetTotal(), PromoteType.FullAmountSentGift); if (sendPromotion != null) { shoppingCartInfo.SendGiftPromotionId = sendPromotion.ActivityId; shoppingCartInfo.SendGiftPromotionName = sendPromotion.Name; shoppingCartInfo.IsSendGift = true; } PromotionInfo sendPromotion2 = new PromotionDao().GetSendPromotion(member, shoppingCartInfo.GetTotal(), PromoteType.FullAmountSentTimesPoint); if (sendPromotion2 != null) { shoppingCartInfo.SentTimesPointPromotionId = sendPromotion2.ActivityId; shoppingCartInfo.SentTimesPointPromotionName = sendPromotion2.Name; shoppingCartInfo.IsSendTimesPoint = true; shoppingCartInfo.TimesPoint = sendPromotion2.DiscountValue; } PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, shoppingCartInfo.GetTotal(), PromoteType.FullAmountSentFreight); if (sendPromotion3 != null) { shoppingCartInfo.FreightFreePromotionId = sendPromotion3.ActivityId; shoppingCartInfo.FreightFreePromotionName = sendPromotion3.Name; shoppingCartInfo.IsFreightFree = true; } } // 促销活动(商品)中的赠送商品 if (cartItemInfo.LinePresentPro != null && cartItemInfo.LinePresentPro.Count > 0) { shoppingCartInfo.LinePresentPro = cartItemInfo.LinePresentPro; } result = shoppingCartInfo; } return(result); }
public static ShoppingCartInfo GetShoppingCart(Member member) { // 支持 App api //Member member = HiContext.Current.User as Member; ShoppingCartInfo result; if (member != null) { ShoppingCartInfo shoppingCart = new ShoppingCartDao().GetShoppingCart(member); if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0) { result = null; } else { decimal reducedPromotionAmount = 0m; PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(member, shoppingCart.GetAmount(), shoppingCart.GetQuantity(), out reducedPromotionAmount); if (reducedPromotion != null) { shoppingCart.ReducedPromotionId = reducedPromotion.ActivityId; shoppingCart.ReducedPromotionName = reducedPromotion.Name; shoppingCart.ReducedPromotionAmount = reducedPromotionAmount; shoppingCart.IsReduced = true; } PromotionInfo sendPromotion = new PromotionDao().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentGift); if (sendPromotion != null) { shoppingCart.SendGiftPromotionId = sendPromotion.ActivityId; shoppingCart.SendGiftPromotionName = sendPromotion.Name; shoppingCart.IsSendGift = true; } PromotionInfo sendPromotion2 = new PromotionDao().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentTimesPoint); if (sendPromotion2 != null) { shoppingCart.SentTimesPointPromotionId = sendPromotion2.ActivityId; shoppingCart.SentTimesPointPromotionName = sendPromotion2.Name; shoppingCart.IsSendTimesPoint = true; shoppingCart.TimesPoint = sendPromotion2.DiscountValue; } PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, shoppingCart.GetTotal(), PromoteType.FullAmountSentFreight); if (sendPromotion3 != null) { shoppingCart.FreightFreePromotionId = sendPromotion3.ActivityId; shoppingCart.FreightFreePromotionName = sendPromotion3.Name; shoppingCart.IsFreightFree = true; } result = shoppingCart; } } else { result = new CookieShoppingDao().GetShoppingCart(); } return(result); }
public static PromotionInfo GetPromotionByProduct(int productId) { PromotionInfo result = null; int? activeIdByProduct = new PromotionDao().GetActiveIdByProduct(productId); if (activeIdByProduct.HasValue) { result = PromoteHelper.GetPromotion(activeIdByProduct.Value); } return(result); }
public static PromotionInfo GetPromotionByProduct(int productId) { PromotionInfo promotion = null; int? activeIdByProduct = new PromotionDao().GetActiveIdByProduct(productId); if (activeIdByProduct.HasValue) { promotion = GetPromotion(activeIdByProduct.Value); } return(promotion); }
public void SetViewBag(long?selectedId = null) { var dao1 = new AuthorDao(); ViewBag.MaTG = new SelectList(dao1.ListAll(), "MaTG", "TenTG", selectedId); var dao2 = new CategoryDao(); ViewBag.MaDM = new SelectList(dao2.ListAll(), "MaDM", "TenDM", selectedId); var dao3 = new PublisherDao(); ViewBag.MaNXB = new SelectList(dao3.ListAll(), "MaNXB", "TenNXB", selectedId); var dao4 = new PromotionDao(); ViewBag.MaKM = new SelectList(dao4.ListAl(), "MaKM", "MaKM", selectedId); }
public ActionResult Edit(KhuyenMai km) { if (ModelState.IsValid) { var dao = new PromotionDao(); var result = dao.Update(km); if (result) { SetAlert("Sửa thông tin khuyến mại thành công", "success"); return(RedirectToAction("Index", "Promotion")); } else { ModelState.AddModelError("", "Cập nhật thông tin khuyến mại không thành công"); } } return(View("Index")); }
public ActionResult Create(KhuyenMai tt) { if (ModelState.IsValid) { var dao = new PromotionDao(); long id = dao.Insert(tt); if (id > 0) { SetAlert("Thêm khuyến mại thành công", "success"); return(RedirectToAction("Index", "Promotion")); } else { ModelState.AddModelError("", "Thêm khuyến mại không thành công"); } } return(View("Index")); }
public static int AddPromotion(PromotionInfo promotion) { Database database = DatabaseFactory.CreateDatabase(); int result; using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { PromotionDao promotionDao = new PromotionDao(); int num = promotionDao.AddPromotion(promotion, dbTransaction); if (num <= 0) { dbTransaction.Rollback(); result = -1; } else { if (!promotionDao.AddPromotionMemberGrades(num, promotion.MemberGradeIds, dbTransaction)) { dbTransaction.Rollback(); result = -2; } else { dbTransaction.Commit(); result = num; } } } catch (Exception var_5_76) { dbTransaction.Rollback(); result = 0; } finally { dbConnection.Close(); } } return(result); }
public static int AddPromotion(PromotionInfo promotion, bool IsMobileExclusive = false) { bool flag = PromoteHelper.ProcessStoreType4PromotionInfo(promotion); Database database = DatabaseFactory.CreateDatabase(); using (DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { PromotionDao promotionDao = new PromotionDao(); int num = (int)promotionDao.Add(promotion, null); if (num <= 0) { dbTransaction.Rollback(); return(-1); } if (flag) { StoreActivityHelper.SaveStoreActivity(promotion.StoreIds, num, 1); } if (!IsMobileExclusive && !promotionDao.AddPromotionMemberGrades(num, promotion.MemberGradeIds, dbTransaction)) { dbTransaction.Rollback(); return(-2); } dbTransaction.Commit(); return(num); } catch (Exception) { dbTransaction.Rollback(); return(0); } finally { dbConnection.Close(); } } }
public static ShoppingCartInfo GetShoppingCartInfoBySkus(Member member, string skuIds) //获取顾客选择的待下单的购物车信息 { string[] skuIdsArray = skuIds.Split(','); HashSet <string> hsSkuIds = new HashSet <string>(); for (int i = 0; i < skuIdsArray.Length; i++) { if (skuIdsArray[i].Trim().Length == 0) { continue; } hsSkuIds.Add(skuIdsArray[i]); } ShoppingCartInfo result = GetShoppingCart(member); //判断购物车是否为空 if (result == null) { return(result); } if (hsSkuIds.Count == result.LineItems.Count) //如果传进来的Sku个数与数据库一致,则返回所有 { return(result); } if (result != null) { List <ShoppingCartItemInfo> listShoppingCartItemInfo = new List <ShoppingCartItemInfo>(); int count = result.LineItems.Count; for (int i = 0; i < count; i++) { if (!hsSkuIds.Contains(result.LineItems[i].SkuId)) { listShoppingCartItemInfo.Add(result.LineItems[i]); } } foreach (ShoppingCartItemInfo item in listShoppingCartItemInfo) { result.LineItems.Remove(item); } if (member != null) { if (result.LineItems.Count == 0 && result.LineGifts.Count == 0) { result = null; } else { decimal reducedPromotionAmount = 0m; PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(member, result.GetAmount(), result.GetQuantity(), out reducedPromotionAmount); if (reducedPromotion != null) { result.ReducedPromotionId = reducedPromotion.ActivityId; result.ReducedPromotionName = reducedPromotion.Name; result.ReducedPromotionAmount = reducedPromotionAmount; result.IsReduced = true; } else { result.IsReduced = false; } PromotionInfo sendPromotion = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentGift); if (sendPromotion != null) { result.SendGiftPromotionId = sendPromotion.ActivityId; result.SendGiftPromotionName = sendPromotion.Name; result.IsSendGift = true; } else { result.IsSendGift = false; } PromotionInfo sendPromotion2 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentTimesPoint); if (sendPromotion2 != null) { result.SentTimesPointPromotionId = sendPromotion2.ActivityId; result.SentTimesPointPromotionName = sendPromotion2.Name; result.IsSendTimesPoint = true; result.TimesPoint = sendPromotion2.DiscountValue; } else { result.IsSendTimesPoint = false; } PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentFreight); if (sendPromotion3 != null) { result.FreightFreePromotionId = sendPromotion3.ActivityId; result.FreightFreePromotionName = sendPromotion3.Name; result.IsFreightFree = true; } else { result.IsFreightFree = false; } } } } return(result); }
public ActionResult Edit(int id) { var xb = new PromotionDao().ViewDetail(id); return(View(xb)); }
public ActionResult Index() { var model = new PromotionDao().ListAll(); return(View(model)); }
public static ShoppingCartInfo GetPartShoppingCartInfo(string skuIds) //获取顾客选择的待下单的购物车信息 { if (!string.IsNullOrEmpty(skuIds)) { skuIds = EcShop.Core.Globals.UrlDecode(skuIds); } string[] skuIdsArray = skuIds.Split(','); HashSet <string> hsSkuIds = new HashSet <string>(); for (int i = 0; i < skuIdsArray.Length; i++) { if (skuIdsArray[i].Trim().Length == 0) { continue; } hsSkuIds.Add(skuIdsArray[i]); } ShoppingCartInfo result = GetShoppingCart(); if (hsSkuIds.Count == 0) { return(result); } List <ShoppingCartItemInfo> listShoppingCartItemInfo = new List <ShoppingCartItemInfo>(); if (result != null) { int count = result.LineItems.Count; for (int i = 0; i < count; i++) { if (hsSkuIds.Contains(result.LineItems[i].SkuId)) { listShoppingCartItemInfo.Add(result.LineItems[i]); } } foreach (ShoppingCartItemInfo item in listShoppingCartItemInfo) { result.LineItems.Remove(item); } Member member = HiContext.Current.User as Member; if (member != null) { if (result.LineItems.Count == 0 && result.LineGifts.Count == 0) { result = null; } else { decimal reducedPromotionAmount = 0m; PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(member, result.GetAmount(), result.GetQuantity(), out reducedPromotionAmount); if (reducedPromotion != null) { result.ReducedPromotionId = reducedPromotion.ActivityId; result.ReducedPromotionName = reducedPromotion.Name; result.ReducedPromotionAmount = reducedPromotionAmount; result.IsReduced = true; } else { result.ReducedPromotionId = 0; result.ReducedPromotionName = ""; result.ReducedPromotionAmount = 0m; result.IsReduced = false; } PromotionInfo sendPromotion = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentGift); if (sendPromotion != null) { result.SendGiftPromotionId = sendPromotion.ActivityId; result.SendGiftPromotionName = sendPromotion.Name; result.IsSendGift = true; } else { result.SendGiftPromotionId = 0; result.SendGiftPromotionName = ""; result.IsSendGift = false; } PromotionInfo sendPromotion2 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentTimesPoint); if (sendPromotion2 != null) { result.SentTimesPointPromotionId = sendPromotion2.ActivityId; result.SentTimesPointPromotionName = sendPromotion2.Name; result.IsSendTimesPoint = true; result.TimesPoint = sendPromotion2.DiscountValue; } else { result.SentTimesPointPromotionId = 0; result.SentTimesPointPromotionName = ""; result.IsSendTimesPoint = false; result.TimesPoint = 0m; } PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentFreight); if (sendPromotion3 != null) { result.FreightFreePromotionId = sendPromotion3.ActivityId; result.FreightFreePromotionName = sendPromotion3.Name; result.IsFreightFree = true; } else { result.FreightFreePromotionId = 0; result.FreightFreePromotionName = ""; result.IsFreightFree = false; } } } } return(result); }
public static ShoppingCartInfo GetCountDownShoppingCart(Member member, string productSkuId, int buyAmount, int storeId) { ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo(); ShoppingCartItemInfo cartItemInfo = new ShoppingCartDao().GetCartItemInfo(member, productSkuId, buyAmount, storeId); ShoppingCartInfo result; if (cartItemInfo == null) { result = null; } else { CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(cartItemInfo.ProductId); if (countDownInfo == null) { result = null; } else { ShoppingCartItemInfo shoppingCartItemInfo = new ShoppingCartItemInfo(); shoppingCartItemInfo.SkuId = cartItemInfo.SkuId; shoppingCartItemInfo.ProductId = cartItemInfo.ProductId; shoppingCartItemInfo.SKU = cartItemInfo.SKU; shoppingCartItemInfo.Name = cartItemInfo.Name; shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = countDownInfo.CountDownPrice); shoppingCartItemInfo.SkuContent = cartItemInfo.SkuContent; //修改数量 shoppingCartItemInfo.ShippQuantity = buyAmount; shoppingCartItemInfo.Quantity = buyAmount; shoppingCartItemInfo.Weight = cartItemInfo.Weight; shoppingCartItemInfo.ThumbnailUrl40 = cartItemInfo.ThumbnailUrl40; shoppingCartItemInfo.ThumbnailUrl60 = cartItemInfo.ThumbnailUrl60; shoppingCartItemInfo.ThumbnailUrl100 = cartItemInfo.ThumbnailUrl100; shoppingCartItemInfo.IsfreeShipping = cartItemInfo.IsfreeShipping; shoppingCartItemInfo.TaxRate = cartItemInfo.TaxRate; shoppingCartItemInfo.MaxTaxRate = cartItemInfo.MaxTaxRate; shoppingCartItemInfo.MinTaxRate = cartItemInfo.MinTaxRate; shoppingCartItemInfo.TemplateId = cartItemInfo.TemplateId; if (cartItemInfo != null && cartItemInfo.CombinationItemInfos != null && cartItemInfo.CombinationItemInfos.Count > 0) { shoppingCartItemInfo.CombinationItemInfos = cartItemInfo.CombinationItemInfos; } shoppingCartInfo.LineItems.Add(shoppingCartItemInfo); //订单满额包邮 PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, (countDownInfo.CountDownPrice) * buyAmount, PromoteType.FullAmountSentFreight); if (sendPromotion3 != null) { shoppingCartInfo.FreightFreePromotionId = sendPromotion3.ActivityId; shoppingCartInfo.FreightFreePromotionName = sendPromotion3.Name; shoppingCartInfo.IsFreightFree = true; } result = shoppingCartInfo; } } return(result); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; string text = context.Request["action"].ToNullString(); if (string.IsNullOrEmpty(text) || text == "") { string text2 = string.Empty; string text3 = context.Request["ckids"]; if (!string.IsNullOrEmpty(text3)) { text2 = text3; } string a2 = context.Request["client"].ToNullString(); ShoppingCartInfo shoppingCartInfo = (!(a2 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(text2, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(text2, false, false, -1); if (shoppingCartInfo != null) { string[] source = text2.Split(','); bool flag = false; bool flag2 = true; bool flag3 = true; foreach (ShoppingCartItemInfo lineItem in shoppingCartInfo.LineItems) { if (source.Contains(lineItem.SkuId) || source.Contains(lineItem.SkuId + "|" + lineItem.StoreId)) { int skuStock = ShoppingCartProcessor.GetSkuStock(lineItem.SkuId, lineItem.StoreId); if (skuStock < lineItem.Quantity) { flag = true; break; } if (HiContext.Current.SiteSettings.OpenMultStore && lineItem.StoreId > 0) { StoresInfo storeById = StoresHelper.GetStoreById(lineItem.StoreId); if (storeById != null) { if (!SettingsManager.GetMasterSettings().Store_IsOrderInClosingTime) { DateTime dateTime = DateTime.Now; string str = dateTime.ToString("yyyy-MM-dd"); dateTime = storeById.OpenStartDate; DateTime value = (str + " " + dateTime.ToString("HH:mm")).ToDateTime().Value; dateTime = DateTime.Now; string str2 = dateTime.ToString("yyyy-MM-dd"); dateTime = storeById.OpenEndDate; DateTime dateTime2 = (str2 + " " + dateTime.ToString("HH:mm")).ToDateTime().Value; if (dateTime2 <= value) { dateTime2 = dateTime2.AddDays(1.0); } if (DateTime.Now < value || DateTime.Now > dateTime2) { flag3 = false; } } if (!storeById.CloseStatus && storeById.CloseEndTime.HasValue && storeById.CloseBeginTime.HasValue && storeById.CloseEndTime.Value > DateTime.Now && storeById.CloseBeginTime.Value < DateTime.Now) { flag2 = false; } } } } } if (flag) { context.Response.ContentType = "text/json"; context.Response.Write("{\"status\":\"false\",\"msg\":\"有商品库存不足,不能结算\"}"); context.Response.End(); } if (!flag3) { context.Response.ContentType = "text/json"; context.Response.Write("{\"status\":\"StoreNotInTime\",\"msg\":\"非营业时间\"}"); context.Response.End(); } if (!flag2) { context.Response.ContentType = "text/json"; context.Response.Write("{\"status\":\"StoreNotOpen\",\"msg\":\"歇业中\"}"); context.Response.End(); } if (shoppingCartInfo != null) { ShoppingCartGiftInfo shoppingCartGiftInfo = (from a in shoppingCartInfo.LineGifts where a.PromoType == 5 select a).FirstOrDefault(); shoppingCartInfo.SendGiftPromotionId = (shoppingCartGiftInfo?.GiftId ?? 0); if (!shoppingCartInfo.IsSendGift && shoppingCartInfo.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo lineGift in shoppingCartInfo.LineGifts) { ShoppingCartProcessor.RemoveGiftItem(lineGift.GiftId, PromoteType.SentGift); } } } string s = JsonConvert.SerializeObject(shoppingCartInfo); context.Response.ContentType = "text/json"; context.Response.Write(s); } } else if (text == "ClearCart") { string text4 = context.Request.Form["ck_productId"].ToNullString(); if (string.IsNullOrEmpty(text4)) { context.Response.Write("{\"status\":\"false\",\"msg\":\"请选择要清除的商品\"}"); } else { string[] array = text4.Split(','); foreach (string text5 in array) { string[] array2 = text5.Split('|'); if (array2.Length == 2) { ShoppingCartProcessor.RemoveLineItem(array2[0], array2[1].ToInt(0)); } else { ShoppingCartProcessor.RemoveLineItem(text5, 0); } } context.Response.Write("{\"status\":\"true\",\"msg\":\"清除成功\"}"); } context.Response.End(); } else if (text == "HasStore") { string text6 = context.Request.Form["skuId"].ToNullString(); SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (string.IsNullOrEmpty(text6) || !masterSettings.OpenMultStore) { context.Response.Write("{\"status\":\"false\"}"); } else if (ShoppingCartProcessor.HasStoreSkuStocks(text6)) { context.Response.Write("{\"status\":\"true\"}"); } else { context.Response.Write("{\"status\":\"false\"}"); } } else if (text == "ProductsHasStore") { string text7 = context.Request.Form["productIds"]; SiteSettings masterSettings2 = SettingsManager.GetMasterSettings(); if (string.IsNullOrEmpty(text7) || !masterSettings2.OpenMultStore) { context.Response.Write("{\"status\":\"false\"}"); } else { string str3 = ShoppingCartProcessor.HasStoreByProducts(text7); context.Response.Write("{\"status\":\"true\",\"productIds\":\"" + str3 + "\"}"); } } else if (text == "updateBuyNum") { string skuid = context.Request.Form["SkuId"].ToNullString().Trim(); int num = context.Request.Form["BuyNum"].ToNullString().Trim().ToInt(0); string a3 = context.Request.Form["client"].ToNullString().Trim(); ShoppingCartInfo shoppingCartInfo2 = (!(a3 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(null, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(null, false, false, -1); ShoppingCartItemInfo shoppingCartItemInfo = shoppingCartInfo2.LineItems.FirstOrDefault((ShoppingCartItemInfo a) => a.SkuId == skuid); int num2 = shoppingCartItemInfo?.Quantity ?? 1; if (num <= 0) { context.Response.Write("{\"status\":\"numError\",\"msg\":\"购买数量必须为大于0的整数\",\"oldNumb\":\"" + num2 + "\"}"); } else if (ShoppingCartProcessor.GetSkuStock(skuid, 0) < num) { context.Response.Write("{\"status\":\"StockError\",\"msg\":\"该商品库存不足\",\"oldNumb\":\"" + num2 + "\"}"); } else { ShoppingCartProcessor.UpdateLineItemQuantity(skuid, num, 0); PromotionInfo productQuantityDiscountPromotion = ShoppingCartProcessor.GetProductQuantityDiscountPromotion(skuid, HiContext.Current.User.GradeId); if (productQuantityDiscountPromotion != null && (decimal)num >= productQuantityDiscountPromotion.Condition) { shoppingCartItemInfo.AdjustedPrice = shoppingCartItemInfo.MemberPrice * productQuantityDiscountPromotion.DiscountValue; } else { shoppingCartItemInfo.AdjustedPrice = shoppingCartItemInfo.MemberPrice; } context.Response.Write("{\"status\":\"true\",\"adjustedPrice\":" + shoppingCartItemInfo.AdjustedPrice.F2ToString("f2") + "}"); } } else if (text == "updateGiftBuyNum") { string giftId = context.Request.Form["giftId"].ToNullString().Trim(); int num3 = context.Request.Form["BuyNum"].ToNullString().Trim().ToInt(0); string a4 = context.Request.Form["client"].ToNullString().Trim(); ShoppingCartInfo shoppingCartInfo3 = (!(a4 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(null, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(null, false, false, -1); ShoppingCartGiftInfo shoppingCartGiftInfo2 = shoppingCartInfo3.LineGifts.FirstOrDefault((ShoppingCartGiftInfo a) => a.GiftId == giftId.ToInt(0)); if (shoppingCartGiftInfo2 == null) { context.Response.Write("{\"status\":\"nullError\",\"msg\":\"该礼品不存在或已删除\",\"oldNumb\":\"" + 0 + "\"}"); } else if (num3 <= 0) { context.Response.Write("{\"status\":\"numError\",\"msg\":\"购买数量必须为大于0的整数\",\"oldNumb\":\"" + shoppingCartGiftInfo2.Quantity + "\"}"); } else { ShoppingCartProcessor.UpdateGiftItemQuantity(giftId.ToInt(0), num3, PromoteType.NotSet); context.Response.Write("{\"status\":\"true\"}"); } } else if (text == "deleteGift") { string text8 = context.Request.Form["giftId"].ToNullString().Trim(); text8 = text8.TrimStart(',').TrimEnd(','); string[] array3 = text8.Split(','); foreach (string text9 in array3) { ShoppingCartProcessor.RemoveGiftItem(text8.ToInt(0), PromoteType.NotSet); } context.Response.Write("{\"status\":\"true\"}"); } else if (text == "deletestore") { string skuId = context.Request.Form["SkuId"].ToNullString().Trim(); int storeId = context.Request.Form["StoreId"].ToInt(0); ShoppingCartProcessor.RemoveLineItem(skuId, storeId); context.Response.Write("{\"status\":\"true\"}"); } else if (text == "delete") { string skuId2 = context.Request.Form["SkuId"].ToNullString().Trim(); ShoppingCartProcessor.RemoveLineItem(skuId2, 0); context.Response.Write("{\"status\":\"true\"}"); } else if (text == "deleteall") { string text10 = context.Request.Form["SkuIdList"].ToNullString().Trim(); if (!string.IsNullOrEmpty(text10.ToNullString().Trim())) { text10 = text10.TrimStart(',').TrimEnd(','); string[] array4 = text10.Split(','); foreach (string skuId3 in array4) { ShoppingCartProcessor.RemoveLineItem(skuId3, 0); } } context.Response.Write("{\"status\":\"true\"}"); } else if (text == "reducedpromotion") { decimal amount = context.Request.Form["Amount"].ToDecimal(0); int quantity = context.Request.Form["Quantity"].ToInt(0); MemberInfo user = HiContext.Current.User; decimal num4 = default(decimal); PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(user.GradeId, amount, quantity, out num4, 0); if (reducedPromotion != null) { context.Response.Write("{\"ReducedPromotionAmount\":\"" + num4 + "\",\"ReducedPromotionCondition\":\"" + reducedPromotion.Condition + "\"}"); } else { context.Response.Write("{\"ReducedPromotionAmount\":\"0\",\"ReducedPromotionCondition\":\"0\"}"); } } }