protected void shoppingCartProductList_ItemCommand(object sender, DataListCommandEventArgs e) { int num; Control control = e.Item.Controls[0]; TextBox box = (TextBox)control.FindControl("txtBuyNum"); Literal literal = (Literal)control.FindControl("litProductId"); Literal literal2 = (Literal)control.FindControl("litSkuId"); if (!int.TryParse(box.Text, out num) || (box.Text.IndexOf(".") != -1)) { this.ShowMessage("购买数量必须为整数", false); } else if (num <= 0) { this.ShowMessage("购买数量必须为大于0的整数", false); } else { if (e.CommandName == "updateBuyNum") { if (ShoppingCartProcessor.GetSkuStock(literal2.Text.Trim()) < num) { this.ShowMessage("该商品库存不够", false); return; } ShoppingCartProcessor.UpdateLineItemQuantity(Convert.ToInt32(literal.Text), literal2.Text, num); } if (e.CommandName == "delete") { ShoppingCartProcessor.RemoveLineItem(literal2.Text); } this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } }
protected bool CheckProductStock(string ckproductids) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, true, -1); if (shoppingCart == null) { return(false); } bool result = true; if (!string.IsNullOrEmpty(ckproductids)) { string[] source = ckproductids.Split(','); foreach (ShoppingCartItemInfo lineItem in shoppingCart.LineItems) { if (source.Contains(lineItem.SkuId)) { int skuStock = ShoppingCartProcessor.GetSkuStock(lineItem.SkuId, 0); if (skuStock < lineItem.Quantity) { result = false; break; } } } } return(result); }
protected void shoppingCartProductList_ItemCommand(object sender, System.Web.UI.WebControls.DataListCommandEventArgs e) { System.Web.UI.Control control = e.Item.Controls[0]; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)control.FindControl("txtBuyNum"); System.Web.UI.WebControls.Literal literal = (System.Web.UI.WebControls.Literal)control.FindControl("litSkuId"); int num; if (!int.TryParse(textBox.Text, out num) || textBox.Text.IndexOf(".") != -1) { this.ShowMessage("购买数量必须为整数", false); return; } if (num <= 0) { this.ShowMessage("购买数量必须为大于0的整数", false); return; } if (e.CommandName == "updateBuyNum") { if (ShoppingCartProcessor.GetSkuStock(literal.Text.Trim()) < num) { this.ShowMessage("该商品库存不够", false); this.btnCheckout.Visible = false; return; } ShoppingCartProcessor.UpdateLineItemQuantity(literal.Text, num); } if (e.CommandName == "delete") { ShoppingCartProcessor.RemoveLineItem(literal.Text); } this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart") + "?productSkuId=" + literal.Text, true); }
protected void btnSKU_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtSKU.Text.Trim())) { this.ShowMessage("请输入货号", false, "", 1); } else { IList <string> skuIdsBysku = ShoppingProcessor.GetSkuIdsBysku(this.txtSKU.Text.Trim()); if (skuIdsBysku == null || skuIdsBysku.Count == 0) { this.ShowMessage("货号无效,请确认后重试", false, "", 1); } else { bool flag = false; foreach (string item in skuIdsBysku) { if (ShoppingCartProcessor.GetSkuStock(item, 0) > 1) { ShoppingCartProcessor.AddLineItem(item, 1, false, 0); } else { flag = true; } } if (flag) { this.ShowMessage("指定的货号库存不足", false, "", 1); } this.BindShoppingCart(); } } }
private void ProcessAddToCartBySkus(System.Web.HttpContext context) { context.Response.ContentType = "application/json"; int quantity = int.Parse(context.Request["quantity"], System.Globalization.NumberStyles.None); string skuId = context.Request["productSkuId"]; //判断库存 int oldQuan = ShoppingCartProcessor.GetSkuStock(skuId); if (quantity > oldQuan) { context.Response.Write("{\"Status\":\"1\",\"oldQuan\":\"" + oldQuan + "\"}"); return; } //检查商品是否超过限购数量 Member member = HiContext.Current.User as Member; if (member != null) { int MaxCount = 0; int Payquantity = ProductHelper.CheckPurchaseCount(skuId, member.UserId, out MaxCount); if ((Payquantity + quantity) > MaxCount && MaxCount != 0) //当前购买数量大于限购剩余购买数量 { context.Response.Write("{\"Status\":\"4\"}"); return; } } if (ShoppingCartProcessor.AddLineItem(skuId, quantity, 0) != AddCartItemStatus.Successed) { context.Response.Write("{\"Status\":\"2\"}"); return; } DataTable dt = ProductHelper.GetAdOrderInfo(skuId); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { context.Response.Write(string.Concat(new object[] { "{\"Status\":\"OK\",\"TotalMoney\":\"", shoppingCart.GetTotal().ToString(".00"), "\",\"Quantity\":\"", shoppingCart.GetQuantity().ToString(), "\",\"SkuQuantity\":\"", shoppingCart.GetQuantity_Sku(skuId), "\",\"data\":", Newtonsoft.Json.JsonConvert.SerializeObject(dt), "}" })); return; } context.Response.Write("{\"Status\":\"3\"}"); }
public static bool CheckShoppingStock(ShoppingCartInfo shoppingcart, out string productinfo) { bool flag = true; productinfo = ""; foreach (ShoppingCartItemInfo info in shoppingcart.LineItems) { if (ShoppingCartProcessor.GetSkuStock(info.SkuId) < info.Quantity) { string str = productinfo; productinfo = str + ((productinfo == "") ? "" : "、") + info.Name + " " + info.SkuContent; flag = false; } } return(flag); }
protected void btnPay_Click(object sender, System.EventArgs e) { OrderInfo orderInfo = TradeHelper.GetOrderInfo(this.orderId); int num = 0; int num2 = 0; int num3 = 0; if (orderInfo.CountDownBuyId > 0) { CountDownInfo countDownBuy = TradeHelper.GetCountDownBuy(orderInfo.CountDownBuyId); if (countDownBuy == null || countDownBuy.EndDate < System.DateTime.Now) { this.ShowMessage("当前的订单为限时抢购订单,此活动已结束,所以不能支付", false); return; } } if (orderInfo.GroupBuyId > 0) { GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(orderInfo.GroupBuyId); if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay) { this.ShowMessage("当前的订单为团购订单,此团购活动已结束,所以不能支付", false); return; } num2 = TradeHelper.GetOrderCount(orderInfo.GroupBuyId); num3 = orderInfo.GetGroupBuyOerderNumber(); num = groupBuy.MaxCount; if (num < num2 + num3) { this.ShowMessage("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false); return; } } if (!orderInfo.CheckAction(OrderActions.BUYER_PAY)) { this.ShowMessage("当前的订单订单状态不是等待付款,所以不能支付", false); return; } if (HiContext.Current.User.UserId != orderInfo.UserId) { this.ShowMessage("预付款只能为自己下的订单付款,查一查该订单是不是你的", false); return; } if ((decimal)this.litUseableBalance.Money < orderInfo.GetTotal()) { this.ShowMessage("预付款余额不足,支付失败", false); return; } IUser user = HiContext.Current.User; user.TradePassword = this.txtPassword.Text; if (Users.ValidTradePassword(user)) { System.Collections.Generic.Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems; foreach (LineItemInfo current in lineItems.Values) { int skuStock = ShoppingCartProcessor.GetSkuStock(current.SkuId); if (skuStock < current.ShipmentQuantity) { this.ShowMessage("订单中商品库存不足,禁止支付!", false); return; } } if (TradeHelper.UserPayOrder(orderInfo, true)) { TradeHelper.SaveDebitNote(new DebitNoteInfo { NoteId = Globals.GetGenerateId(), OrderId = this.orderId, Operator = HiContext.Current.User.Username, Remark = "客户预付款订单支付成功" }); if (orderInfo.GroupBuyId > 0 && num == num2 + num3) { TradeHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId); } Messenger.OrderPayment(user, orderInfo, orderInfo.GetTotal()); orderInfo.OnPayment(); this.Page.Response.Redirect(Globals.ApplicationPath + "/user/PaySucceed.aspx?orderId=" + this.orderId); return; } this.ShowMessage(string.Format("对订单{0} 支付失败", orderInfo.OrderId), false); return; } else { this.ShowMessage("交易密码有误,请重试", false); } }
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\"}"); } } }
private void rptCartProducts_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (HiContext.Current.User.UserId != 0 && (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)) { Control control = e.Item.Controls[0]; Literal literal = control.FindControl("ltlSKUContent") as Literal; Repeater repeater = control.FindControl("repProductGifts") as Repeater; Control control2 = control.FindControl("divChangeAmount"); Control control3 = control.FindControl("ck_productId"); Control control4 = control.FindControl("lblNoStock"); Control control5 = control.FindControl("lblInValid"); Control control6 = control.FindControl("divQuantity"); ShoppingCartItemInfo itemInfo = e.Item.DataItem as ShoppingCartItemInfo; if (!itemInfo.IsValid) { control2.Visible = false; control6.Visible = true; control3.Visible = false; control4.Visible = false; control5.Visible = true; } else { control5.Visible = false; string[] array = itemInfo.SkuContent.Split(';'); string text = string.Empty; string[] array2 = array; foreach (string text2 in array2) { string[] array3 = text2.Split(':'); if (array3.Length == 2) { text = text + " " + array3[1] + " /"; } } string text3 = text; char[] trimChars = new char[1] { '/' }; text = (literal.Text = text3.TrimEnd(trimChars)); int skuStock = ShoppingCartProcessor.GetSkuStock(itemInfo.SkuId, 0); if (skuStock < itemInfo.Quantity || skuStock <= 0) { control2.Visible = false; control3.Visible = false; control4.Visible = true; control6.Visible = true; } else { control4.Visible = false; control6.Visible = false; } } PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(itemInfo.ProductId); if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift) { List <ShoppingCartGiftInfo> cartGiftList = new List <ShoppingCartGiftInfo>(); IList <GiftInfo> giftDetailsByGiftIds = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds); giftDetailsByGiftIds.ForEach(delegate(GiftInfo gift) { ShoppingCartGiftInfo shoppingCartGiftInfo = new ShoppingCartGiftInfo(); shoppingCartGiftInfo.GiftId = gift.GiftId; shoppingCartGiftInfo.CostPrice = (gift.CostPrice.HasValue ? gift.CostPrice.Value : decimal.Zero); shoppingCartGiftInfo.PromoType = 5; shoppingCartGiftInfo.Quantity = itemInfo.ShippQuantity; shoppingCartGiftInfo.Weight = gift.Weight; shoppingCartGiftInfo.Volume = gift.Volume; shoppingCartGiftInfo.NeedPoint = gift.NeedPoint; shoppingCartGiftInfo.Name = gift.Name; shoppingCartGiftInfo.ThumbnailUrl100 = gift.ThumbnailUrl100; shoppingCartGiftInfo.ThumbnailUrl180 = gift.ThumbnailUrl180; shoppingCartGiftInfo.ThumbnailUrl40 = gift.ThumbnailUrl40; shoppingCartGiftInfo.ThumbnailUrl60 = gift.ThumbnailUrl60; shoppingCartGiftInfo.IsExemptionPostage = gift.IsExemptionPostage; shoppingCartGiftInfo.ShippingTemplateId = gift.ShippingTemplateId; cartGiftList.Add(shoppingCartGiftInfo); }); repeater.DataSource = cartGiftList; repeater.DataBind(); } } }
private void SelectItem(System.Web.HttpContext context) { string skuId = context.Request["skuId"]; string skuIds = context.Request["pids"]; int num = 1; int.TryParse(context.Request["quantity"], out num); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{"); int skuStock = ShoppingCartProcessor.GetSkuStock(skuId); if (num > skuStock) { stringBuilder.AppendFormat("\"Status\":\"{0}\"", skuStock); num = skuStock; stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); } ShoppingCartProcessor.UpdateLineItemQuantity(skuId, (num > 0) ? num : 1); if (skuIds == null) { stringBuilder.Append("\"Success\":0"); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); } ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetPartShoppingCartInfo(skuIds); if (shoppingCart == null || shoppingCart.LineItems.Count == 0) { stringBuilder.Append("\"Success\":1,"); stringBuilder.Append("\"AmoutPrice\":\"0.00\","); stringBuilder.Append("\"ReducedPromotion\":\"0.00\","); stringBuilder.Append("\"ReducedPromotionName\":\"\","); stringBuilder.Append("\"Tax\":\"0.00\","); stringBuilder.Append("\"ActivityReduct\":\"0.00\","); stringBuilder.Append("\"TotalPrice\":\"0.00\""); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); context.Response.End(); return; } HttpCookie cookie = new HttpCookie("UserSession-SkuIds"); cookie.Value = Globals.UrlEncode(skuIds); cookie.Expires = DateTime.Now.AddDays(1); context.Response.AppendCookie(cookie); stringBuilder.Append("\"Success\":1,"); stringBuilder.AppendFormat("\"AmoutPrice\":\"{0}\",", shoppingCart.GetNewAmount().ToString("F2")); stringBuilder.AppendFormat("\"ReducedPromotion\":\"{0}\",", shoppingCart.ReducedPromotionAmount.ToString("F2")); stringBuilder.AppendFormat("\"ReducedPromotionName\":\"{0}\",", shoppingCart.ReducedPromotionName); decimal tax = shoppingCart.CalTotalTax(); stringBuilder.AppendFormat("\"Tax\":\"{0}\",", tax.ToString("F2")); decimal activityReduct = shoppingCart.GetActivityPrice(); stringBuilder.AppendFormat("\"ActivityReduct\":\"{0}\",", activityReduct == 0 ? "0.00" : activityReduct.ToString("F2")); stringBuilder.AppendFormat("\"NavigateUrl\":\"{0}\",", Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[] { shoppingCart.ReducedPromotionId }).ClearForJson()); stringBuilder.AppendFormat("\"TotalPrice\":\"{0}\"", shoppingCart.GetNewTotalIncludeTax().ToString("F2")); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); }
private void shoppingCartProductList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { TextBox textBox = (TextBox)e.Item.FindControl("txtBuyNum"); Control control = e.Item.FindControl("spanStock"); Control control2 = e.Item.FindControl("divAmount"); Control control3 = e.Item.FindControl("divCheck"); Control control4 = e.Item.FindControl("divNoCheck"); Control control5 = e.Item.FindControl("divInValid"); Control control6 = e.Item.FindControl("divIsStock"); Control control7 = e.Item.FindControl("divValidInfo"); if (HiContext.Current.User.UserId == 0) { control5.Visible = false; control6.Visible = false; control4.Visible = false; control7.Visible = false; } else { Repeater repeater = e.Item.FindControl("rptPromotionGifts") as Repeater; ShoppingCartItemInfo shoppingCartItemInfo = e.Item.DataItem as ShoppingCartItemInfo; PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(shoppingCartItemInfo.ProductId); if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift) { IList <GiftInfo> list = (IList <GiftInfo>)(repeater.DataSource = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds)); repeater.DataBind(); } if (!shoppingCartItemInfo.IsValid) { control3.Visible = false; control5.Visible = true; control7.Visible = true; control6.Visible = false; control2.Visible = false; } else { control5.Visible = false; control7.Visible = false; control6.Visible = false; int num = default(int); int.TryParse(textBox.Text, out num); int skuStock = ShoppingCartProcessor.GetSkuStock(shoppingCartItemInfo.SkuId, 0); if (skuStock < num || skuStock <= 0) { control.Visible = true; control2.Visible = false; control3.Visible = false; control4.Visible = true; control6.Visible = true; this.btnCheckout.Style.Add(HtmlTextWriterStyle.Display, "none"); this.btnUnCheckout.Visible = true; } else { control4.Visible = false; } } } } }
protected void btnPay_Click(object sender, EventArgs e) { MemberInfo user = HiContext.Current.User; if (string.IsNullOrEmpty(user.TradePassword)) { this.Page.Response.Redirect("/user/OpenBalance.aspx"); } string empty = string.Empty; OrderInfo orderInfo = TradeHelper.GetOrderInfo(this.orderId); int num = 0; int num2 = 0; int num3 = 0; if (orderInfo.CountDownBuyId > 0) { foreach (KeyValuePair <string, LineItemInfo> lineItem in orderInfo.LineItems) { CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(lineItem.Value.ProductId, orderInfo.CountDownBuyId, lineItem.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, out empty, orderInfo.StoreId); if (countDownInfo == null) { this.ShowMessage(empty, false, "", 1); return; } } } if (orderInfo.FightGroupId > 0) { foreach (KeyValuePair <string, LineItemInfo> lineItem2 in orderInfo.LineItems) { FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem2.Value.ProductId, orderInfo.FightGroupActivityId, orderInfo.FightGroupId, lineItem2.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, lineItem2.Value.Quantity, out empty); if (fightGroupActivityInfo == null) { this.ShowMessage(empty, false, "", 1); return; } } } if (orderInfo.GroupBuyId > 0) { GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(orderInfo.GroupBuyId); if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay) { this.ShowMessage("当前的订单为团购订单,此团购活动已结束,所以不能支付", false, "", 1); return; } num2 = TradeHelper.GetOrderCount(orderInfo.GroupBuyId); num3 = orderInfo.GetGroupBuyOerderNumber(); num = groupBuy.MaxCount; if (num < num2 + num3) { this.ShowMessage("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false, "", 1); return; } } if (orderInfo.PreSaleId > 0) { ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(orderInfo.PreSaleId); if (productPreSaleInfo == null) { this.ShowMessage("预售活动不存在不能支付", false, "", 1); return; } if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && productPreSaleInfo.PreSaleEndDate < DateTime.Now) { this.ShowMessage("您支付晚了,预售活动已经结束", false, "", 1); return; } if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay) { if (productPreSaleInfo.PaymentStartDate > DateTime.Now) { this.ShowMessage("尾款支付尚未开始", false, "", 1); return; } DateTime dateTime = productPreSaleInfo.PaymentEndDate; DateTime date = dateTime.Date; dateTime = DateTime.Now; if (date < dateTime.Date) { this.ShowMessage("尾款支付已结束", false, "", 1); return; } } } if (!orderInfo.CheckAction(OrderActions.BUYER_PAY)) { this.ShowMessage("当前的订单订单状态不是等待付款,所以不能支付", false, "", 1); } else if (HiContext.Current.UserId != orderInfo.UserId) { this.ShowMessage("预付款只能为自己下的订单付款,查一查该订单是不是你的", false, "", 1); } else if ((decimal)this.litUseableBalance.Money < orderInfo.GetTotal(false)) { this.ShowMessage("预付款余额不足,支付失败", false, "", 1); } else if (MemberProcessor.ValidTradePassword(this.txtPassword.Text)) { string str = ""; if (!TradeHelper.CheckOrderStock(orderInfo, out str)) { this.ShowMessage("订单中有商品(" + str + ")库存不足", false, "", 1); } else { Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems; foreach (LineItemInfo value in lineItems.Values) { int skuStock = ShoppingCartProcessor.GetSkuStock(value.SkuId, 0); if (skuStock < value.ShipmentQuantity) { this.ShowMessage("订单中商品库存不足,禁止支付!", false, "", 1); return; } } if (TradeHelper.UserPayOrder(orderInfo, true, false)) { if (orderInfo.GroupBuyId > 0 && num == num2 + num3) { TradeHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId); } if (orderInfo.ParentOrderId == "-1") { OrderQuery orderQuery = new OrderQuery(); orderQuery.ParentOrderId = orderInfo.OrderId; IList <OrderInfo> listUserOrder = MemberProcessor.GetListUserOrder(orderInfo.UserId, orderQuery); foreach (OrderInfo item in listUserOrder) { OrderHelper.OrderConfirmPaySendMessage(item); } } else { OrderHelper.OrderConfirmPaySendMessage(orderInfo); } this.Page.Response.Redirect("/user/PaySucceed.aspx?orderId=" + this.orderId); } else { this.ShowMessage($"对订单{orderInfo.OrderId} 支付失败", false, "", 1); } } } else { this.ShowMessage("交易密码有误,请重试", false, "", 1); } }