public void btnCreateOrder_Click(object sender, EventArgs e) { if (ValidateCreateOrder()) { OrderInfo orderInfo = GetOrderInfo(shoppingCart); if (shoppingCart.Quantity > 1) { isSignBuy = false; } if (orderInfo == null) { ShowMessage("购物车中已经没有任何商品", false); } else if (!HiContext.Current.User.IsAnonymous && (shoppingCart.GetTotalNeedPoint() > ((Member)HiContext.Current.User).Points)) { ShowMessage("您当前的积分不够兑换所需积分!", false); } else if (isCountDown && (ProductBrowser.GetCountDownInfo(shoppingCart.LineItems[productSku].ProductId).EndDate < DateTime.Now)) { ShowMessage("此订单为抢购订单,但抢购时间已到!", false); } else { try { if (ShoppingProcessor.CreatOrder(orderInfo)) { Messenger.OrderCreated(orderInfo, HiContext.Current.User); orderInfo.OnCreated(); if (shoppingCart.GetTotalNeedPoint() > 0) { ShoppingProcessor.CutNeedPoint(shoppingCart.GetTotalNeedPoint()); } if ((!isCountDown && !isGroupBuy) && !isSignBuy) { ShoppingCartProcessor.ClearShoppingCart(); } if (!HiContext.Current.User.IsAnonymous && (PersonalHelper.GetShippingAddressCount(HiContext.Current.User.UserId) == 0)) { ShippingAddressInfo shippingAddress = new ShippingAddressInfo(); shippingAddress.UserId = HiContext.Current.User.UserId; shippingAddress.ShipTo = Globals.HtmlEncode(txtShipTo.Text); shippingAddress.RegionId = dropRegions.GetSelectedRegionId().Value; shippingAddress.Address = Globals.HtmlEncode(txtAddress.Text); shippingAddress.Zipcode = txtZipcode.Text; shippingAddress.CellPhone = txtCellPhone.Text; shippingAddress.TelPhone = txtTelPhone.Text; PersonalHelper.CreateShippingAddress(shippingAddress); } Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("FinishOrder", new object[] { orderInfo.OrderId })); } } catch (Exception exception) { ShowMessage(exception.ToString(), false); } } } }
public void btnCreateOrder_Click(object sender, System.EventArgs e) { if (this.ValidateCreateOrder()) { OrderInfo orderInfo = this.GetOrderInfo(this.shoppingCart); if (this.shoppingCart.GetQuantity() > 1) { this.isSignBuy = false; } if (orderInfo == null) { this.ShowMessage("购物车中已经没有任何商品", false); } else { if (orderInfo.GetTotal() < 0m) { this.ShowMessage("订单金额不能为负", false); } else { if (!Hidistro.Membership.Context.HiContext.Current.User.IsAnonymous) { int totalNeedPoint = this.shoppingCart.GetTotalNeedPoint(); int points = ((Hidistro.Membership.Context.Member)Hidistro.Membership.Context.HiContext.Current.User).Points; if (points >= 0 && totalNeedPoint > points) { this.ShowMessage("您当前的积分不够兑换所需积分!", false); return; } } if (this.isCountDown) { CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(this.shoppingCart.LineItems[this.productSku].ProductId); if (countDownInfo.EndDate < System.DateTime.Now) { this.ShowMessage("此订单为抢购订单,但抢购时间已到!", false); return; } if (this.shoppingCart.LineItems[this.productSku].Quantity > countDownInfo.MaxCount) { this.ShowMessage("你购买的数量超过限购数量:" + countDownInfo.MaxCount.ToString(), false); return; } int num = ShoppingProcessor.CountDownOrderCount(this.shoppingCart.LineItems[this.productSku].ProductId); if (num + this.shoppingCart.LineItems[this.productSku].Quantity > countDownInfo.MaxCount) { this.ShowMessage(string.Format("你已经抢购过该商品{0}件,每个用户只允许抢购{1}件,如果你有未付款的抢购单,请及时支付!", num, countDownInfo.MaxCount), false); return; } } try { if (ShoppingProcessor.CreatOrder(orderInfo)) { Messenger.OrderCreated(orderInfo, Hidistro.Membership.Context.HiContext.Current.User); orderInfo.OnCreated(); if (this.shoppingCart.GetTotalNeedPoint() > 0) { ShoppingProcessor.CutNeedPoint(this.shoppingCart.GetTotalNeedPoint(), orderInfo.OrderId); } if (!this.isCountDown && !this.isGroupBuy && !this.isSignBuy && !this.isBundling) { ShoppingCartProcessor.ClearShoppingCart(); } if (!Hidistro.Membership.Context.HiContext.Current.User.IsAnonymous && PersonalHelper.GetShippingAddressCount(Hidistro.Membership.Context.HiContext.Current.User.UserId) == 0) { PersonalHelper.CreateShippingAddress(new ShippingAddressInfo { UserId = Hidistro.Membership.Context.HiContext.Current.User.UserId, ShipTo = Globals.HtmlEncode(this.txtShipTo.Text), RegionId = this.dropRegions.GetSelectedRegionId().Value, Address = Globals.HtmlEncode(this.txtAddress.Text), Zipcode = this.txtZipcode.Text, CellPhone = this.txtCellPhone.Text, TelPhone = this.txtTelPhone.Text }); } this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("FinishOrder", new object[] { orderInfo.OrderId })); } } catch (System.Exception ex) { this.ShowMessage(ex.ToString(), false); } } } } }