예제 #1
0
        void BindShoppingCart()
        {
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart == null)
            {
                this.pnlShopCart.Visible  = false;
                this.litNoProduct.Visible = true;
                ShoppingCartProcessor.ClearShoppingCart();
            }
            else
            {
                this.pnlShopCart.Visible  = true;
                this.litNoProduct.Visible = false;
                this.BindDiscountName(shoppingCart);
                if (shoppingCart.LineItems.Values.Count > 0)
                {
                    this.shoppingCartProductList.DataSource = shoppingCart.LineItems.Values;
                    this.shoppingCartProductList.DataBind();
                    this.shoppingCartProductList.ShowProductCart();
                }
                if (shoppingCart.LineGifts.Count > 0)
                {
                    this.shoppingCartGiftList.DataSource = shoppingCart.LineGifts;
                    this.shoppingCartGiftList.DataBind();
                    this.shoppingCartGiftList.ShowGiftCart();
                }
                this.lblAmoutPrice.Money = shoppingCart.GetAmount();
                this.lblTotalPrice.Money = shoppingCart.GetTotal();
            }
        }
예제 #2
0
        /// <summary>
        /// 删除全部产品
        /// </summary>
        /// <returns></returns>
        private ActionResult ProcessDeleteAllFromCart()
        {
            ShoppingCartProcessor.ClearShoppingCart();
            string callback = QueryString.SafeQ("callback");//jsonp回调函数

            return(Content(callback + "({\"Status\":\"OK\"})"));
        }
예제 #3
0
        private void BindShoppingCart()
        {
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart == null)
            {
                this.pnlShopCart.Visible  = false;
                this.litNoProduct.Visible = true;
                ShoppingCartProcessor.ClearShoppingCart();
            }
            else
            {
                this.pnlShopCart.Visible  = true;
                this.litNoProduct.Visible = false;
                if (shoppingCart.LineItems.Values.Count > 0)
                {
                    this.shoppingCartProductList.DataSource = shoppingCart.LineItems.Values;
                    this.shoppingCartProductList.DataBind();
                    this.shoppingCartProductList.ShowProductCart();
                }
                if (shoppingCart.LineGifts.Count > 0)
                {
                    System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable =
                        from shoppingCartGiftInfo_0 in shoppingCart.LineGifts
                        where shoppingCartGiftInfo_0.PromoType == 0
                        select shoppingCartGiftInfo_0;
                    System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 =
                        from shoppingCartGiftInfo_0 in shoppingCart.LineGifts
                        where shoppingCartGiftInfo_0.PromoType == 5
                        select shoppingCartGiftInfo_0;
                    this.shoppingCartGiftList.DataSource     = enumerable;
                    this.shoppingCartGiftList.FreeDataSource = enumerable2;
                    this.shoppingCartGiftList.DataBind();
                    this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0);
                }
                if (shoppingCart.IsSendGift)
                {
                    int num = 1;
                    int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift);
                    System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts();
                    if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0)
                    {
                        this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts;
                        this.shoppingCartPromoGiftList.DataBind();
                        this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num);
                    }
                }
                if (shoppingCart.IsReduced)
                {
                    this.lblAmoutPrice.Text              = string.Format("商品金额:{0}", shoppingCart.GetAmount().ToString("F2"));
                    this.hlkReducedPromotion.Text        = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2"));
                    this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
                    {
                        shoppingCart.ReducedPromotionId
                    });
                }
                this.lblTotalPrice.Money = shoppingCart.GetTotal();
            }
        }
예제 #4
0
 private void BindShoppingCart()
 {
     this.cartInfo = ShoppingCartProcessor.GetShoppingCart(null, true, true, -1);
     if (this.cartInfo == null)
     {
         this.pnlShopCart.Visible  = false;
         this.pnlNoProduct.Visible = true;
         ShoppingCartProcessor.ClearShoppingCart();
     }
     else
     {
         this.pnlShopCart.Visible  = true;
         this.pnlNoProduct.Visible = false;
         if (this.cartInfo.LineItems.Count > 0)
         {
             this.shoppingCartProductList.ListCartItems = this.cartInfo.LineItems;
             this.shoppingCartProductList.settings      = this.setting;
             this.shoppingCartProductList.DataBind();
             this.shoppingCartProductList.ShowProductCart();
             this.shoppingCartStoreList.ListCartItems = this.cartInfo.LineItems;
             this.shoppingCartStoreList.DataBind();
         }
         if (this.cartInfo.LineGifts.Count > 0)
         {
             IEnumerable <ShoppingCartGiftInfo> enumerable = from s in this.cartInfo.LineGifts
                                                             where s.PromoType == 0
                                                             select s;
             IEnumerable <ShoppingCartGiftInfo> enumerable2 = from s in this.cartInfo.LineGifts
                                                              where s.PromoType == 5
                                                              select s;
             this.hidPointGifts.Value             = enumerable.Count().ToString();
             this.shoppingCartGiftList.DataSource = enumerable;
             this.shoppingCartGiftList.DataBind();
             this.shoppingCartGiftList.ShowGiftCart(enumerable.Count() > 0);
         }
         this.lblTotalPrice.Money = this.cartInfo.GetTotal(false);
     }
 }
예제 #5
0
        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);
                    }
                }
            }
        }
예제 #6
0
 protected void btnClearCart_Click(object sender, EventArgs e)
 {
     ShoppingCartProcessor.ClearShoppingCart();
     this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true);
 }
예제 #7
0
        private void BindShoppingCart()
        {
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart == null)
            {
                this.pnlShopCart.Visible  = false;
                this.pnlNoProduct.Visible = true;
                ShoppingCartProcessor.ClearShoppingCart();
                return;
            }
            this.pnlShopCart.Visible  = true;
            this.pnlNoProduct.Visible = false;
            if (shoppingCart.LineItems.Count > 0)
            {
                decimal tax = shoppingCart.CalTotalTax();
                if (tax <= 50)
                {
                    this.lblTax.Text = string.Format("商品关税:<span style='text-decoration: line-through;'>{0}</span>", tax.ToString("F2"));
                }
                else
                {
                    this.lblTax.Text = string.Format("商品关税:{0}", tax.ToString("F2"));
                }
                //this.lblTax.Text = string.Format("商品关税:{0}", tax <50 ? "0.00" : tax.ToString("F2"));
                //foreach (ShoppingCartItemInfo item in shoppingCart.LineItems)
                //{
                //    item.TaxRate = Math.Round(item.TaxRate * 100, 0);
                //}

                decimal activityReduct = shoppingCart.GetActivityPrice();
                this.lblReducedActivity.Text = string.Format("活动优惠:{0}", activityReduct == 0 ? "0.00" : activityReduct.ToString("F2"));

                this.lblTotalPrice.Money = shoppingCart.GetNewTotalIncludeTax();

                var query = from q in shoppingCart.LineItems
                            group q by new { id = q.SupplierId }
                into g
                    select new
                {
                    SupplierId     = g.FirstOrDefault().SupplierId,
                    SupplierName   = g.FirstOrDefault().SupplierName,
                    Logo           = g.FirstOrDefault().Logo,
                    ProductId      = g.FirstOrDefault().ProductId,
                    SkuId          = g.FirstOrDefault().SkuId,
                    Name           = g.FirstOrDefault().Name,
                    ThumbnailUrl60 = g.FirstOrDefault().ThumbnailUrl60,
                    TaxRate        = g.FirstOrDefault().TaxRate,
                    MemberPrice    = g.FirstOrDefault().MemberPrice,
                    Quantity       = g.FirstOrDefault().Quantity,
                    SKU            = g.FirstOrDefault().SKU,
                    ShippQuantity  = g.FirstOrDefault().ShippQuantity,
                    PromotionId    = g.FirstOrDefault().PromotionId,
                    PromotionName  = g.FirstOrDefault().PromotionName,
                    SubNewTotal    = g.FirstOrDefault().SubNewTotal,
                    NewTaxRate     = GetNewTaxRate(g.FirstOrDefault().TaxRate, g.FirstOrDefault().MinTaxRate, g.FirstOrDefault().MaxTaxRate)
                                     //itemInfo  = g.FirstOrDefault()
                };
                this.shoppingCartProductList.DataSource = query;
                this.shoppingCartProductList.DataBind();
                this.shoppingCartProductList.ShowProductCart();
            }
            if (shoppingCart.LineGifts.Count > 0)
            {
                System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable =
                    from s in shoppingCart.LineGifts
                    where s.PromoType == 0
                    select s;
                System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 =
                    from s in shoppingCart.LineGifts
                    where s.PromoType == 5
                    select s;
                this.shoppingCartGiftList.DataSource     = enumerable;
                this.shoppingCartGiftList.FreeDataSource = enumerable2;
                this.shoppingCartGiftList.DataBind();
                this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0);
            }
            if (shoppingCart.IsSendGift)
            {
                int num = 1;
                int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift);
                System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts();
                if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0)
                {
                    this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts;
                    this.shoppingCartPromoGiftList.DataBind();
                    this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num);
                }
            }

            //if (shoppingCart.IsReduced)
            //{
            this.lblAmoutPrice.Text       = string.Format("商品金额:{0}", shoppingCart.GetNewAmount().ToString("F2"));
            this.hlkReducedPromotion.Text = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2"));
            if (shoppingCart.ReducedPromotionId != 0)
            {
                this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
                {
                    shoppingCart.ReducedPromotionId
                });
            }
            //}

            HttpCookie cookieSkuIds = this.Page.Request.Cookies["UserSession-SkuIds"];

            if (cookieSkuIds != null)
            {
                //cookieSkuIds.Expires = DateTime.Now.AddDays(-1);
                this.Page.Response.AppendCookie(cookieSkuIds);
            }
        }
예제 #8
0
 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);
                 }
             }
         }
     }
 }