public static ShoppingCartInfo GetCountDownShoppingCart(string productSkuId, int buyAmount)
        {
            ShoppingCartInfo     info  = new ShoppingCartInfo();
            Member               user  = HiContext.Current.User as Member;
            ShoppingCartItemInfo info2 = ShoppingProvider.Instance().GetCartItemInfo(user, productSkuId, buyAmount);

            if (info2 == null)
            {
                return(null);
            }
            CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(info2.ProductId);

            if (countDownInfo == null)
            {
                return(null);
            }
            ShoppingCartItemInfo info4 = new ShoppingCartItemInfo();

            info4.SkuId           = info2.SkuId;
            info4.ProductId       = info2.ProductId;
            info4.SKU             = info2.SKU;
            info4.Name            = info2.Name;
            info4.MemberPrice     = info4.AdjustedPrice = countDownInfo.CountDownPrice;
            info4.SkuContent      = info2.SkuContent;
            info4.Quantity        = info4.ShippQuantity = buyAmount;
            info4.Weight          = info2.Weight;
            info4.ThumbnailUrl40  = info2.ThumbnailUrl40;
            info4.ThumbnailUrl60  = info2.ThumbnailUrl60;
            info4.ThumbnailUrl100 = info2.ThumbnailUrl100;
            info.LineItems.Add(productSkuId, info4);
            return(info);
        }
        private OrderInfo GetOrderInfo(ShoppingCartInfo shoppingCartInfo)
        {
            OrderInfo orderInfo = ShoppingProcessor.ConvertShoppingCartToOrder(shoppingCartInfo, this.isGroupBuy, this.isCountDown, this.isSignBuy);

            if (orderInfo == null)
            {
                return(null);
            }
            if (this.chkTax.Checked)
            {
                orderInfo.Tax = (orderInfo.GetTotal() * decimal.Parse(this.litTaxRate.Text)) / 100M;
                if (this.isBundling)
                {
                    BundlingInfo bundlingInfo = ProductBrowser.GetBundlingInfo(this.bundlingid);
                    orderInfo.Tax = (bundlingInfo.Price * decimal.Parse(this.litTaxRate.Text)) / 100M;
                }
            }
            orderInfo.InvoiceTitle = this.txtInvoiceTitle.Text;
            if (this.isGroupBuy)
            {
                GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo(shoppingCartInfo.LineItems[this.productSku].ProductId);
                orderInfo.GroupBuyId = productGroupBuyInfo.GroupBuyId;
                orderInfo.NeedPrice  = productGroupBuyInfo.NeedPrice;
            }
            if (this.isCountDown)
            {
                CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(this.shoppingCart.LineItems[this.productSku].ProductId);
                orderInfo.CountDownBuyId = countDownInfo.CountDownId;
            }
            if (this.isBundling)
            {
                BundlingInfo info5 = ProductBrowser.GetBundlingInfo(this.bundlingid);
                orderInfo.BundlingID    = info5.BundlingID;
                orderInfo.BundlingPrice = info5.Price;
                orderInfo.Points        = this.shoppingCart.GetPoint(info5.Price);
            }
            orderInfo.OrderId   = this.GenerateOrderId();
            orderInfo.OrderDate = DateTime.Now;
            IUser user = HiContext.Current.User;

            orderInfo.UserId   = user.UserId;
            orderInfo.Username = user.Username;
            if (!user.IsAnonymous)
            {
                Member member = user as Member;
                orderInfo.EmailAddress = member.Email;
                orderInfo.RealName     = member.RealName;
                orderInfo.QQ           = member.QQ;
                orderInfo.Wangwang     = member.Wangwang;
                orderInfo.MSN          = member.MSN;
            }
            orderInfo.Remark       = Globals.HtmlEncode(this.txtMessage.Text);
            orderInfo.OrderStatus  = OrderStatus.WaitBuyerPay;
            orderInfo.RefundStatus = RefundStatus.None;
            this.FillOrderCoupon(orderInfo);
            this.FillOrderShippingMode(orderInfo, shoppingCartInfo);
            this.FillOrderPaymentMode(orderInfo);
            return(orderInfo);
        }
        public static ShoppingCartInfo GetCountDownShoppingCart(string productSkuId, int buyAmount)
        {
            int               num;
            int               num2;
            string            str2;
            ProductSaleStatus status;
            ShoppingCartInfo  info             = new ShoppingCartInfo();
            DataTable         productInfoBySku = ShoppingProcessor.GetProductInfoBySku(productSkuId);

            if ((productInfoBySku == null) || (productInfoBySku.Rows.Count <= 0))
            {
                return(null);
            }
            CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo((int)productInfoBySku.Rows[0]["ProductId"]);

            if (countDownInfo == null)
            {
                return(null);
            }
            string skuContent = string.Empty;

            foreach (DataRow row in productInfoBySku.Rows)
            {
                if (!((((row["AttributeName"] == DBNull.Value) || string.IsNullOrEmpty((string)row["AttributeName"])) || (row["ValueStr"] == DBNull.Value)) || string.IsNullOrEmpty((string)row["ValueStr"])))
                {
                    object obj2 = skuContent;
                    skuContent = string.Concat(new object[] { obj2, row["AttributeName"], ":", row["ValueStr"], "; " });
                }
            }
            ShoppingProvider     provider = ShoppingProvider.Instance();
            Member               user     = HiContext.Current.User as Member;
            ShoppingCartItemInfo info3    = provider.GetCartItemInfo(user, (int)productInfoBySku.Rows[0]["ProductId"], productSkuId, skuContent, buyAmount, out status, out str2, out num, out num2);

            if ((((info3 == null) || (status != ProductSaleStatus.OnSale)) || (num <= 0)) || (num < num2))
            {
                return(null);
            }
            ShoppingCartItemInfo info4 = new ShoppingCartItemInfo(info3.SkuId, info3.ProductId, info3.SKU, info3.Name, countDownInfo.CountDownPrice, info3.SkuContent, buyAmount, info3.Weight, 0, string.Empty, 0, 0, string.Empty, null, info3.CategoryId, info3.ThumbnailUrl40, info3.ThumbnailUrl60, info3.ThumbnailUrl100);

            info.LineItems.Add(productSkuId, info4);
            return(info);
        }
        public static ShoppingCartInfo GetCountDownShoppingCart(string productSkuId, int buyAmount)
        {
            ShoppingCartInfo     shoppingCartInfo = new ShoppingCartInfo();
            Member               member           = HiContext.Current.User as Member;
            ShoppingCartItemInfo cartItemInfo     = ShoppingProvider.Instance().GetCartItemInfo(member, productSkuId, buyAmount);
            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 arg_C3_0 = shoppingCartItemInfo;
                    shoppingCartItemInfo.ShippQuantity = buyAmount;
                    arg_C3_0.Quantity                    = buyAmount;
                    shoppingCartItemInfo.Weight          = cartItemInfo.Weight;
                    shoppingCartItemInfo.ThumbnailUrl40  = cartItemInfo.ThumbnailUrl40;
                    shoppingCartItemInfo.ThumbnailUrl60  = cartItemInfo.ThumbnailUrl60;
                    shoppingCartItemInfo.ThumbnailUrl100 = cartItemInfo.ThumbnailUrl100;
                    shoppingCartInfo.LineItems.Add(productSkuId, shoppingCartItemInfo);
                    result = shoppingCartInfo;
                }
            }
            return(result);
        }
Beispiel #5
0
        protected override void AttachChildControls()
        {
            this.litShipTo           = (Literal)this.FindControl("litShipTo");
            this.litCellPhone        = (Literal)this.FindControl("litCellPhone");
            this.litAddress          = (Literal)this.FindControl("litAddress");
            this.rptCartProducts     = (VshopTemplatedRepeater)this.FindControl("rptCartProducts"); //商品
            this.rptCartGifts        = (VshopTemplatedRepeater)this.FindControl("rptCartGifts");    //礼品
            this.dropShippingType    = (Common_ShippingTypeSelect)this.FindControl("dropShippingType");
            this.dropCoupon          = (Common_CouponSelect)this.FindControl("dropCoupon");
            this.dropRedPager        = (Common_UserRedPagerSelect)this.FindControl("dropRedPager");
            this.dropStreets         = (Common_StreetSelect)this.FindControl("dropStreets"); //街道下拉框
            this.dropAgents          = (Common_AgentSelect)this.FindControl("dropAgents");   //天使下拉框
            this.litOrderTotal       = (Literal)this.FindControl("litOrderTotal");
            this.litTotalPoint       = (Literal)this.FindControl("litTotalPoint");           //所需积分
            this.isSelectAgentEnable = (HtmlInputHidden)this.FindControl("isSelectAgentEnable");
            this.hiddenCartTotal     = (HtmlInputHidden)this.FindControl("hiddenCartTotal");
            this.aLinkToShipping     = (HtmlAnchor)this.FindControl("aLinkToShipping");
            this.groupbuyHiddenBox   = (HtmlInputControl)this.FindControl("groupbuyHiddenBox");
            this.countdownHiddenBox  = (HtmlInputControl)this.FindControl("countdownHiddenBox");
            this.cutdownHiddenBox    = (HtmlInputControl)this.FindControl("cutdownHiddenBox");
            this.couponRecharge      = (HtmlInputHidden)this.FindControl("couponRecharge");
            this.usercount           = (HtmlInputHidden)this.FindControl("usercount");
            this.rptAddress          = (VshopTemplatedRepeater)this.FindControl("rptAddress");
            this.selectShipTo        = (HtmlInputHidden)this.FindControl("selectShipTo");
            this.regionId            = (HtmlInputHidden)this.FindControl("regionId");
            Literal literal = (Literal)this.FindControl("litProductTotalPrice");

            this.litExemption      = (Literal)this.FindControl("litExemption");
            this.litAddAddress     = (Literal)this.FindControl("litAddAddress");
            this.isStreetEnable    = (HtmlInputHidden)this.FindControl("isStreetEnable");
            this.isStreetMatch     = (HtmlInputHidden)this.FindControl("isStreetMatch");
            this.claimcode         = (HtmlInputHidden)this.FindControl("claimcode");
            this.litExemption.Text = "0.00";
            IList <ShippingAddressInfo> shippingAddresses = MemberProcessor.GetShippingAddresses();

            this.rptAddress.DataSource = from item in shippingAddresses
                                         orderby item.IsDefault
                                         select item;

            this.rptAddress.DataBind();
            this.rptCartProducts.ItemDataBound += new RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            ShippingAddressInfo info = shippingAddresses.FirstOrDefault <ShippingAddressInfo>(item => item.IsDefault);

            if (info == null)
            {
                info = (shippingAddresses.Count > 0) ? shippingAddresses[0] : null;
            }

            if (info != null)
            {
                this.litShipTo.Text    = info.ShipTo;
                this.litCellPhone.Text = info.CellPhone;
                this.litAddress.Text   = info.Address;
                this.selectShipTo.SetWhenIsNotNull(info.ShippingId.ToString());
                this.regionId.SetWhenIsNotNull(info.RegionId.ToString());
            }
            this.litAddAddress.Text = " href='/Vshop/AddShippingAddress.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString() + "'";
            if (CustomConfigHelper.Instance.IsProLa)
            {
                this.litAddAddress.Text = " href='/Vshop/AddShippingAddressPro.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString() + "'";
            }
            if ((shippingAddresses == null) || (shippingAddresses.Count == 0))
            {
                this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/AddShippingAddress.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString());
            }
            else
            {
                this.aLinkToShipping.HRef = Globals.ApplicationPath + "/Vshop/ShippingAddresses.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString();
                ShoppingCartInfo shoppingCart = null;
                string           msg          = "";
                string           str          = this.Page.Request.QueryString["from"];
                if (((int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"])) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"])) && ((this.Page.Request.QueryString["from"] == "signBuy") || (this.Page.Request.QueryString["from"] == "groupBuy") || (this.Page.Request.QueryString["from"] == "countDown") || (this.Page.Request.QueryString["from"] == "cutDown")))
                {
                    this.productSku = this.Page.Request.QueryString["productSku"];

                    //团购//待完善
                    if ((str == "groupBuy") && int.TryParse(this.Page.Request.QueryString["groupbuyId"], out this.groupBuyId))
                    {
                        this.groupbuyHiddenBox.SetWhenIsNotNull(this.groupBuyId.ToString());
                        shoppingCart = ShoppingCartProcessor.GetGroupBuyShoppingCart(this.groupBuyId, this.productSku, this.buyAmount);
                    }
                    //限时抢购
                    else if ((str == "countDown") && int.TryParse(this.Page.Request.QueryString["countdownId"], out this.countDownId))
                    {
                        this.countdownHiddenBox.SetWhenIsNotNull(this.countDownId.ToString());
                        CountDownInfo info4 = ProductBrowser.GetCountDownInfo(this.countDownId, this.buyAmount, out msg);
                        if (info4 == null)
                        {
                            base.GotoResourceNotFound(msg);
                            return;
                        }
                        if (string.IsNullOrEmpty(this.productSku) || (this.productSku.Split(new char[] { '_' })[0] != info4.ProductId.ToString()))
                        {
                            base.GotoResourceNotFound("错误的商品信息");
                            return;
                        }

                        shoppingCart = ShoppingCartProcessor.GetCountDownShoppingCart(this.productSku, this.buyAmount);
                    }
                    //砍价
                    else if ((str == "cutDown") && int.TryParse(this.Page.Request.QueryString["cutDownId"], out this.cutDownId))
                    {
                        this.cutdownHiddenBox.SetWhenIsNotNull(this.cutDownId.ToString());
                        CutDownInfo info5 = PromoteHelper.GetCutDown(this.cutDownId);
                        if (info5 == null)
                        {
                            base.GotoResourceNotFound();
                            return;
                        }
                        if (string.IsNullOrEmpty(this.productSku) || (this.productSku.Split(new char[] { '_' })[0] != info5.ProductId.ToString()))
                        {
                            base.GotoResourceNotFound("错误的商品信息");
                            return;
                        }

                        shoppingCart = ShoppingCartProcessor.GetCutDownShoppingCart(this.productSku, this.buyAmount, info5.CutDownId);
                    }
                    else
                    {
                        shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.productSku, this.buyAmount);
                    }
                }
                else
                {
                    shoppingCart = ShoppingCartProcessor.GetShoppingCart();
                }



                //获取/新建了购物车对象后,进行商品价格根据分销商特殊优惠设置进行减价处理.
                MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                int        distributorid = Globals.GetCurrentDistributorId();
                //根据分销商的特殊优惠设置进行计算返佣
                switch (SettingsManager.GetMasterSettings(false).DistributorCutOff)
                {
                case "default":    //直接退出,没有任何操作一切照常
                    break;

                case "bycostprice":                            //根据进货价进行返佣
                    if (currentMember.UserId != distributorid) //如果不是分销商购买自己的产品,则退出特殊处理
                    {
                        break;
                    }
                    for (int i = 0; i < shoppingCart.LineItems.Count; i++)
                    {
                        shoppingCart.LineItems[i].AdjustedPrice = ProductHelper.GetSkuCostPrice(shoppingCart.LineItems[i].SkuId);
                    }
                    break;

                default:                                       //根据指定折扣进行返佣(此种情况下,不存在直接分佣)
                    if (currentMember.UserId != distributorid) //如果不是分销商购买自己的产品,则退出特殊处理
                    {
                        break;
                    }
                    decimal rate = Convert.ToDecimal(SettingsManager.GetMasterSettings(false).DistributorCutOff) / 100;    //获取折扣比例
                    for (int i = 0; i < shoppingCart.LineItems.Count; i++)
                    {
                        shoppingCart.LineItems[i].AdjustedPrice = shoppingCart.LineItems[i].AdjustedPrice * rate;
                    }
                    break;
                }

                if (shoppingCart != null)
                {
                    //根据购物车内商品名是否为[会员充值]和是否开启了会员充值送优惠券的功能来给隐藏域赋值,前端js再进行相应的隐藏显示,默认选中等处理
                    if (shoppingCart.LineItems.Where(n => n.Name == "会员充值") != null && shoppingCart.LineItems.Where(n => n.Name == "会员充值").Count() == 1 && CustomConfigHelper.Instance.CouponRecharge)
                    {
                        this.couponRecharge.Value = "1";
                    }
                    else
                    {
                        this.couponRecharge.Value = "0";
                    }
                    //提交订单前先检查是否达到规则要求上限
                    if (!TradeHelper.CheckShoppingStock(shoppingCart, out msg))
                    {
                        this.ShowMessage("订单中有商品(" + msg + ")库存不足", false);
                        if (!this.Page.ClientScript.IsClientScriptBlockRegistered("AlertStockScript"))
                        {
                            StringBuilder builder = new StringBuilder();
                            builder.AppendLine("var stockError = true;");
                            builder.AppendLine(string.Format("var stockErrorInfo=\"订单中有商品({0})库存不足,请返回购物车修改库存.\";", msg));
                            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "AlertStockScript", "var stockError=true;function AlertStock(){alert('订单中有商品(" + msg + ")库存不足,请返回购物车修改库存.');}", true);
                        }
                    }

                    //当前用户已使用的优惠券信息
                    DataTable userCoupon = CouponHelper.GetUserCoupons(currentMember.UserId, 2);    //代表已使用的
                    if (userCoupon.Rows.Count > 0)
                    {
                        this.usercount.Value = "1";
                    }
                    else
                    {
                        ////把当前用户所有优惠券信息取出来
                        DataTable userCouponList = CouponHelper.GetUserCoupons(currentMember.UserId, 1);    //1代表未使用的,有效期内的
                        ////对当前购物车shoppingCart.LineItems进行循环查找,如果优惠券的categoryId与商品的品类不匹配,把优惠券的claimcode取出来放到隐藏域内,传递到前台,前台再进行相关的隐藏操作
                        foreach (ShoppingCartItemInfo shopp in shoppingCart.LineItems)
                        {
                            foreach (DataRow coupon in userCouponList.Rows)
                            {
                                if (!Convert.IsDBNull(coupon["CategoryId"]))
                                {
                                    int cp = Convert.ToInt32(coupon["CategoryId"]);
                                    if (shopp.CategoryId != cp && cp != 0)
                                    {
                                        claimcode.Value += coupon["ClaimCode"].ToString() + ";";
                                    }
                                }
                            }
                        }
                    }
                    claimcode.Value = claimcode.Value.TrimEnd(';');


                    this.rptCartProducts.DataSource = shoppingCart.LineItems;
                    this.rptCartProducts.DataBind();
                    //绑定礼品
                    this.rptCartGifts.DataSource = shoppingCart.LineGifts;
                    this.rptCartGifts.DataBind();
                    //绑定配送方式
                    this.dropShippingType.ShoppingCartItemInfo = shoppingCart.LineItems;
                    this.dropShippingType.RegionId             = 0;
                    this.dropShippingType.Weight = shoppingCart.Weight;
                    this.dropCoupon.CartTotal    = shoppingCart.GetTotal();

                    //addby hj 2015-04-23(迪蔓)
                    this.isSelectAgentEnable.Value = CustomConfigHelper.Instance.SelectServerAgent.ToString();
                    //addby hj 2015-12-25(爽爽挝咖)
                    //给出是否开启街道选择和门店配送功能的标识
                    this.isStreetEnable.Value = Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.AutoShipping.ToString();
                    //绑定街道下拉框
                    if (this.isStreetEnable.Value == "True")
                    {
                        DataTable dtStreetsInfo = Hidistro.ControlPanel.Sales.SalesHelper.GetStreetInfo(regionId.Value.ToString());
                        if (dtStreetsInfo.Rows.Count > 0)
                        {
                            this.dropStreets.StreetsInfo = dtStreetsInfo;
                            this.isStreetMatch.Value     = "True";
                        }
                        else//此种情况下消费者的所在区域内并没有相应的配送店铺,给出提示,页面无法提交
                        {
                            this.isStreetMatch.Value = "False";
                        }
                    }
                    string    noCouponIds    = string.Empty;
                    string    tempCategoryId = string.Empty;
                    DataTable dtDB           = CouponHelper.GetCouponAllCate(); //new DataTable();//设置的使用权限的有效期内的优惠卷 两表关联信息
                    foreach (DataRow dr in dtDB.Rows)
                    {
                        tempCategoryId = "," + dr["CategoryIds"].ToString() + ",";
                        decimal dAmount = (decimal)dr["Amount"];

                        //计算排除掉不能参与的分类金额
                        //shoppingCart.LineItems
                        decimal dAmount2 = dropCoupon.CartTotal;
                        foreach (ShoppingCartItemInfo scii in shoppingCart.LineItems)
                        {
                            if (tempCategoryId.IndexOf("," + scii.CategoryId + ",") > -1)
                            {
                                dAmount2 -= scii.SubTotal;
                            }
                        }

                        //待排除的
                        if (dAmount > dAmount2)
                        {
                            noCouponIds += dr["CouponId"] + ",";
                        }
                    }
                    if (noCouponIds != "")
                    {
                        noCouponIds = noCouponIds.TrimEnd(',');
                    }
                    this.dropCoupon.CouponIds   = noCouponIds;
                    this.dropRedPager.CartTotal = shoppingCart.GetTotal();
                    this.hiddenCartTotal.Value  = literal.Text = shoppingCart.GetTotal().ToString("F2");
                    decimal num = this.DiscountMoney(shoppingCart.LineItems);
                    this.litOrderTotal.Text = (shoppingCart.GetTotal() - num).ToString("F2");
                    this.litTotalPoint.Text = getTotalPoints(shoppingCart).ToString();
                    this.litExemption.Text  = num.ToString("0.00");
                }
                else
                {
                    this.Page.Response.Redirect("/Vshop/ShoppingCart.aspx");
                }
                PageTitle.AddSiteNameTitle("订单确认");
            }
        }
Beispiel #6
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);
                    }
                }
            }
        }
Beispiel #7
0
        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);
        }
 protected override void AttachChildControls()
 {
     if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId))
     {
         base.GotoResourceNotFound();
     }
     this.common_Location         = (Common_Location)this.FindControl("common_Location");
     this.litProductCode          = (Literal)this.FindControl("litProductCode");
     this.litProductName          = (Literal)this.FindControl("litProductName");
     this.lblSku                  = (SkuLabel)this.FindControl("lblSku");
     this.lblStock                = (StockLabel)this.FindControl("lblStock");
     this.litUnit                 = (Literal)this.FindControl("litUnit");
     this.litWeight               = (WeightLabel)this.FindControl("litWeight");
     this.litBrosedNum            = (Literal)this.FindControl("litBrosedNum");
     this.litBrand                = (Literal)this.FindControl("litBrand");
     this.lblSalePrice            = (FormatedMoneyLabel)this.FindControl("lblSalePrice");
     this.lblTotalPrice           = (TotalLabel)this.FindControl("lblTotalPrice");
     this.litDescription          = (Literal)this.FindControl("litDescription");
     this.litShortDescription     = (Literal)this.FindControl("litShortDescription");
     this.btnOrder                = (BuyButton)this.FindControl("btnOrder");
     this.hpkProductConsultations = (HyperLink)this.FindControl("hpkProductConsultations");
     this.hpkProductReviews       = (HyperLink)this.FindControl("hpkProductReviews");
     this.lblCurrentSalePrice     = (FormatedMoneyLabel)this.FindControl("lblCurrentSalePrice");
     this.litContent              = (Literal)this.FindControl("litContent");
     this.lblEndTime              = (FormatedTimeLabel)this.FindControl("lblEndTime");
     this.litRemainTime           = (Literal)this.FindControl("litRemainTime");
     this.images                  = (Common_ProductImages)this.FindControl("common_ProductImages");
     this.rptExpandAttributes     = (ThemedTemplatedRepeater)this.FindControl("rptExpandAttributes");
     this.skuSelector             = (SKUSelector)this.FindControl("SKUSelector");
     this.reviews                 = (Common_ProductReview)this.FindControl("list_Common_ProductReview");
     this.consultations           = (Common_ProductConsultations)this.FindControl("list_Common_ProductConsultations");
     this.correlative             = (Common_GoodsList_Correlative)this.FindControl("list_Common_GoodsList_Correlative");
     if (!this.Page.IsPostBack)
     {
         ProductBrowseInfo info          = ProductBrowser.GetProductBrowseInfo(this.productId, new int?(this.reviews.MaxNum), new int?(this.consultations.MaxNum));
         CountDownInfo     countDownInfo = ProductBrowser.GetCountDownInfo(this.productId);
         if ((info.Product == null) || (countDownInfo == null))
         {
             this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("该件商品参与的限时抢购活动已经结束;或被管理员删除"));
         }
         else
         {
             this.LoadPageSearch(info.Product);
             this.hpkProductReviews.Text              = "查看全部" + ProductBrowser.GetProductReviewNumber(this.productId).ToString() + "条评论";
             this.hpkProductConsultations.Text        = "查看全部" + ProductBrowser.GetProductConsultationNumber(this.productId).ToString() + "条咨询";
             this.hpkProductConsultations.NavigateUrl = string.Format("ProductConsultationsAndReplay.aspx?productId={0}", this.productId);
             this.hpkProductReviews.NavigateUrl       = string.Format("LookProductReviews.aspx?productId={0}", this.productId);
             this.LoadProductInfo(info.Product, info.BrandName);
             this.LoadProductGroupBuyInfo(countDownInfo);
             this.btnOrder.Stock = info.Product.Stock;
             BrowsedProductQueue.EnQueue(this.productId);
             this.images.ImageInfo = info.Product;
             if (info.DbAttribute != null)
             {
                 this.rptExpandAttributes.DataSource = info.DbAttribute;
                 this.rptExpandAttributes.DataBind();
             }
             if (info.DbSKUs != null)
             {
                 this.skuSelector.ProductId  = this.productId;
                 this.skuSelector.DataSource = info.DbSKUs;
             }
             if (info.DBReviews != null)
             {
                 this.reviews.DataSource = info.DBReviews;
                 this.reviews.DataBind();
             }
             if (info.DBConsultations != null)
             {
                 this.consultations.DataSource = info.DBConsultations;
                 this.consultations.DataBind();
             }
             if (info.DbCorrelatives != null)
             {
                 this.correlative.DataSource = info.DbCorrelatives;
                 this.correlative.DataBind();
             }
         }
     }
 }
Beispiel #9
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);
                 }
             }
         }
     }
 }
Beispiel #10
0
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId))
            {
                base.GotoResourceNotFound();
            }
            if (!int.TryParse(this.Page.Request.QueryString["countDownId"], out this.countDownId))
            {
                base.GotoResourceNotFound();
            }
            this.common_Location         = (Common_Location)this.FindControl("common_Location");
            this.litProductCode          = (System.Web.UI.WebControls.Literal) this.FindControl("litProductCode");
            this.litProductName          = (System.Web.UI.WebControls.Literal) this.FindControl("litProductName");
            this.lblSku                  = (SkuLabel)this.FindControl("lblSku");
            this.lblStock                = (StockLabel)this.FindControl("lblStock");
            this.litUnit                 = (System.Web.UI.WebControls.Literal) this.FindControl("litUnit");
            this.litWeight               = (System.Web.UI.WebControls.Label) this.FindControl("litWeight");
            this.litBrosedNum            = (System.Web.UI.WebControls.Literal) this.FindControl("litBrosedNum");
            this.litBrand                = (System.Web.UI.WebControls.Literal) this.FindControl("litBrand");
            this.litmaxcount             = (System.Web.UI.WebControls.Literal) this.FindControl("litMaxCount");
            this.lblSalePrice            = (FormatedMoneyLabel)this.FindControl("lblSalePrice");
            this.lblTotalPrice           = (TotalLabel)this.FindControl("lblTotalPrice");
            this.litDescription          = (System.Web.UI.WebControls.Literal) this.FindControl("litDescription");
            this.litShortDescription     = (System.Web.UI.WebControls.Literal) this.FindControl("litShortDescription");
            this.btnOrder                = (BuyButton)this.FindControl("btnOrder");
            this.hpkProductConsultations = (System.Web.UI.WebControls.HyperLink) this.FindControl("hpkProductConsultations");
            this.hpkProductReviews       = (System.Web.UI.WebControls.HyperLink) this.FindControl("hpkProductReviews");
            this.lblCurrentSalePrice     = (FormatedMoneyLabel)this.FindControl("lblCurrentSalePrice");
            this.litContent              = (System.Web.UI.WebControls.Literal) this.FindControl("litContent");
            this.lblEndTime              = (FormatedTimeLabel)this.FindControl("lblEndTime");
            this.lblStartTime            = (FormatedTimeLabel)this.FindControl("lblStartTime");
            this.litRemainTime           = (System.Web.UI.WebControls.Literal) this.FindControl("litRemainTime");
            this.images                  = (Common_ProductImages)this.FindControl("common_ProductImages");
            this.rptExpandAttributes     = (ThemedTemplatedRepeater)this.FindControl("rptExpandAttributes");
            this.skuSelector             = (SKUSelector)this.FindControl("SKUSelector");
            this.reviews                 = (Common_ProductReview)this.FindControl("list_Common_ProductReview");
            this.consultations           = (Common_ProductConsultations)this.FindControl("list_Common_ProductConsultations");
            this.correlative             = (Common_GoodsList_Correlative)this.FindControl("list_Common_GoodsList_Correlative");
            this.nowTime                 = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("nowTime");
            this.nowTime.SetWhenIsNotNull(System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
            this.hidden_skus       = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hidden_skus");
            this.hidden_skuItem    = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hidden_skuItem");
            this.hiddeCategoryId   = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddeCategoryId");
            this.hiddeCategoryName = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddeCategoryName");
            this.hiddeProductName  = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddeProductName");
            this.hiddeProductCode  = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddeProductCode");
            this.hiddeActiveTime   = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddeActiveTime");


            if (!this.Page.IsPostBack)
            {
                ProductBrowseInfo productBrowseInfo = ProductBrowser.GetProductBrowseInfo(this.productId, new int?(this.reviews.MaxNum), new int?(this.consultations.MaxNum));
                CountDownInfo     countDownInfo     = ProductBrowser.GetCountDownInfo(this.productId, countDownId);
                if (productBrowseInfo.Product == null || countDownInfo == null)
                {
                    this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("该件商品参与的限时抢购活动已经结束;或被管理员删除"));
                    return;
                }
                System.Collections.IEnumerable value =
                    from item in productBrowseInfo.Product.Skus
                    select item.Value;
                if (JsonConvert.SerializeObject(productBrowseInfo.DbSKUs) != null)
                {
                    this.hidden_skuItem.Value = JsonConvert.SerializeObject(productBrowseInfo.DbSKUs);
                }
                if (this.hidden_skus != null)
                {
                    this.hidden_skus.Value = JsonConvert.SerializeObject(value);
                }
                this.hiddeCategoryId.Value   = productBrowseInfo.CategoryId;
                this.hiddeCategoryName.Value = productBrowseInfo.CategoryName;
                this.hiddeProductName.Value  = productBrowseInfo.Product.ProductName;
                this.hiddeProductCode.Value  = productBrowseInfo.Product.ProductCode;

                this.LoadPageSearch(productBrowseInfo.Product);
                this.hpkProductReviews.Text              = "查看全部" + productBrowseInfo.ReviewCount.ToString() + "条评论";
                this.hpkProductConsultations.Text        = "查看全部" + productBrowseInfo.ConsultationCount.ToString() + "条咨询";
                this.hpkProductConsultations.NavigateUrl = string.Format("ProductConsultationsAndReplay.aspx?productId={0}", this.productId);
                this.hpkProductReviews.NavigateUrl       = string.Format("LookProductReviews.aspx?productId={0}", this.productId);
                this.LoadProductInfo(productBrowseInfo.Product, productBrowseInfo.BrandName);
                this.LoadProductGroupBuyInfo(countDownInfo);
                this.btnOrder.Stock = productBrowseInfo.Product.Stock;
                BrowsedProductQueue.EnQueue(this.productId);
                this.images.ImageInfo = productBrowseInfo.Product;
                if (productBrowseInfo.DbAttribute != null)
                {
                    this.rptExpandAttributes.DataSource = productBrowseInfo.DbAttribute;
                    this.rptExpandAttributes.DataBind();
                }
                if (productBrowseInfo.DbSKUs != null)
                {
                    this.skuSelector.ProductId  = this.productId;
                    this.skuSelector.DataSource = productBrowseInfo.DbSKUs;
                }
                if (productBrowseInfo.DBReviews != null)
                {
                    this.reviews.DataSource = productBrowseInfo.DBReviews;
                    this.reviews.DataBind();
                }
                if (productBrowseInfo.DBConsultations != null)
                {
                    this.consultations.DataSource = productBrowseInfo.DBConsultations;
                    this.consultations.DataBind();
                }
                if (productBrowseInfo.DbCorrelatives != null)
                {
                    this.correlative.DataSource = productBrowseInfo.DbCorrelatives;
                    this.correlative.DataBind();
                }
            }
        }