Beispiel #1
0
        private void LoadGroupBuy(GroupBuyInfo groupBuy, decimal salePrice)
        {
            this.txtCount.Text                   = groupBuy.Count.ToString();
            this.txtPrice.Text                   = groupBuy.Price.ToString("F");
            this.txtContent.Text                 = Globals.HtmlDecode(groupBuy.Content);
            this.txtMaxCount.Text                = groupBuy.MaxCount.ToString();
            this.txtNeedPrice.Text               = groupBuy.NeedPrice.ToString("F");
            this.calendarEndDate.SelectedDate    = new System.DateTime?(groupBuy.EndDate.Date);
            this.calendarStartDate.SelectedDate  = new System.DateTime?(groupBuy.StartDate.Date);
            this.drophours.SelectedValue         = new int?(groupBuy.StartDate.Hour);
            this.HourDropDownList1.SelectedValue = new int?(groupBuy.EndDate.Hour);
            ProductInfo productBaseInfo = ProductHelper.GetProductBaseInfo(groupBuy.ProductId);

            this.productName.Text           = productBaseInfo.ProductName;
            this.ProductId.Text             = groupBuy.ProductId.ToString();
            this.ViewState["oridProductId"] = groupBuy.ProductId;
            this.lblPrice.Text = salePrice.ToString("F2");
        }
Beispiel #2
0
        private void grdGroupBuyList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy((int)grdGroupBuyList.DataKeys[e.RowIndex].Value);

            if ((groupBuy.Status == GroupBuyStatus.UnderWay) || (groupBuy.Status == GroupBuyStatus.EndUntreated))
            {
                ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false);
            }
            else if (SubsitePromoteHelper.DeleteGroupBuy((int)grdGroupBuyList.DataKeys[e.RowIndex].Value))
            {
                BindGroupBuy();
                ShowMsg("成功删除了选择的团购活动", true);
            }
            else
            {
                ShowMsg("删除失败", false);
            }
        }
Beispiel #3
0
        public static bool CloseTransaction(OrderInfo order)
        {
            ManagerHelper.CheckPrivilege(Privilege.EditOrders);
            order.OrderStatus = OrderStatus.Closed;
            bool flag = new OrderDao().UpdateOrder(order, null);

            if (order.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy(order.GroupBuyId);
                groupBuy.SoldCount -= order.GetGroupBuyProductQuantity();
                GroupBuyHelper.UpdateGroupBuy(groupBuy);
            }
            if (flag)
            {
                EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "关闭了订单“{0}”", new object[] { order.OrderId }));
            }
            return(flag);
        }
Beispiel #4
0
        private void grdGroupBuyList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GroupBuyInfo groupBuy = GroupBuyHelper.GetGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value);

            if ((groupBuy.StartDate < DateTime.Now) && ((groupBuy.Status == GroupBuyStatus.UnderWay) || (groupBuy.Status == GroupBuyStatus.EndUntreated)))
            {
                this.ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false);
            }
            else if (GroupBuyHelper.DeleteGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value))
            {
                this.BindGroupBuy();
                this.ShowMsg("成功删除了选择的团购活动", true);
            }
            else
            {
                this.ShowMsg("删除失败", false);
            }
        }
        public static ShoppingCartInfo GetGroupBuyShoppingCart(string productSkuId, int buyAmount)
        {
            int               num3;
            int               num4;
            string            str2;
            ProductSaleStatus status;
            ShoppingCartInfo  info             = new ShoppingCartInfo();
            DataTable         productInfoBySku = ShoppingProcessor.GetProductInfoBySku(productSkuId);

            if ((productInfoBySku == null) || (productInfoBySku.Rows.Count <= 0))
            {
                return(null);
            }
            GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo((int)productInfoBySku.Rows[0]["ProductId"]);

            if (productGroupBuyInfo == null)
            {
                return(null);
            }
            int     orderCount   = ProductBrowser.GetOrderCount(productGroupBuyInfo.GroupBuyId);
            decimal currentPrice = ProductBrowser.GetCurrentPrice(productGroupBuyInfo.GroupBuyId, orderCount);
            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 num3, out num4);

            if ((((info3 == null) || (status != ProductSaleStatus.OnSale)) || (num3 <= 0)) || (num3 < num4))
            {
                return(null);
            }
            ShoppingCartItemInfo info4 = new ShoppingCartItemInfo(info3.SkuId, info3.ProductId, info3.SKU, info3.Name, currentPrice, 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);
        }
Beispiel #6
0
        /// <summary>
        /// 页面加载方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void PageLoad()
        {
            base.PageLoad();

            int id = RequestHelper.GetQueryString <int>("ID");

            groupBuy = GroupBuyBLL.ReadGroupBuy(id);
            TimeSpan timeSpan = groupBuy.EndDate - RequestHelper.DateNow;

            leftTime = timeSpan.Days * 24 * 3600 + timeSpan.Hours * 3600 + timeSpan.Minutes * 60 + timeSpan.Seconds;
            buyCount = UserGroupBuyBLL.ReadUserGroupBuyCount(id);
            product  = ProductBLL.ReadProduct(groupBuy.ProductID);
            Title    = product.Name + " - 商品团购";

            int count = 0;
            GroupBuySearchInfo groupBuySearch = new GroupBuySearchInfo();

            groupBuySearch.Status = GroupBuyStatus.Normal;
            groupBuyList          = GroupBuyBLL.ReadGroupBuyList(1, 8, groupBuySearch, ref count);

            string productIDList = string.Empty;
            string idList        = string.Empty;

            foreach (GroupBuyInfo groupBuyInfo in groupBuyList)
            {
                if (productIDList == string.Empty)
                {
                    productIDList = groupBuyInfo.ProductID.ToString();
                    idList        = groupBuyInfo.ID.ToString();
                }
                else
                {
                    productIDList += "," + groupBuyInfo.ProductID.ToString();
                    idList        += "," + groupBuyInfo.ID.ToString();
                }
            }
            //读取商品
            if (productIDList != string.Empty)
            {
                ProductSearchInfo productSearch = new ProductSearchInfo();
                productSearch.InProductID = productIDList;
                productList = ProductBLL.SearchProductList(productSearch);
            }
        }
Beispiel #7
0
        public static bool AddGroupBuy(GroupBuyInfo groupBuy)
        {
            Globals.EntityCoding(groupBuy, true);
            Database database = DatabaseFactory.CreateDatabase();
            bool     result;

            using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
            {
                dbConnection.Open();
                System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                try
                {
                    int num = PromotionsProvider.Instance().AddGroupBuy(groupBuy, dbTransaction);
                    if (num <= 0)
                    {
                        dbTransaction.Rollback();
                        result = false;
                    }
                    else
                    {
                        if (!PromotionsProvider.Instance().AddGroupBuyCondition(num, groupBuy.GroupBuyConditions, dbTransaction))
                        {
                            dbTransaction.Rollback();
                            result = false;
                        }
                        else
                        {
                            dbTransaction.Commit();
                            result = true;
                        }
                    }
                }
                catch (Exception)
                {
                    dbTransaction.Rollback();
                    result = false;
                }
                finally
                {
                    dbConnection.Close();
                }
            }
            return(result);
        }
        private void HasActivitiesToJumpUrl()
        {
            string        text          = string.Empty;
            CountDownInfo countDownInfo = PromoteHelper.ActiveCountDownByProductId(this.productId, 0);
            GroupBuyInfo  groupBuyInfo  = PromoteHelper.ActiveGroupBuyByProductId(this.productId);

            if (countDownInfo != null)
            {
                text = "/{0}/CountDownProductsDetails.aspx?countDownId=" + countDownInfo.CountDownId;
            }
            else if (groupBuyInfo != null)
            {
                text = "/{0}/GroupBuyProductDetails.aspx?groupBuyId=" + groupBuyInfo.GroupBuyId;
            }
            if (!string.IsNullOrEmpty(text))
            {
                this.Page.Response.Redirect(this.FillStringURL(text));
            }
        }
        private static void checkCanGroupBuy(int quantity, int groupBuyId)
        {
            GroupBuyInfo groupBuy = GroupBuyBrowser.GetGroupBuy(groupBuyId);

            if (groupBuy.Status != GroupBuyStatus.UnderWay)
            {
                throw new OrderException("当前团购状态不允许购买");
            }
            if ((groupBuy.StartDate > DateTime.Now) || (groupBuy.EndDate < DateTime.Now))
            {
                throw new OrderException("当前不在团购时间范围内");
            }
            int num = groupBuy.MaxCount - groupBuy.SoldCount;

            if (quantity > num)
            {
                throw new OrderException("剩余可购买团购数量不够");
            }
        }
Beispiel #10
0
        private static void checkCanGroupBuy(int quantity, int groupBuyId)
        {
            GroupBuyInfo info = null;

            if (info.Status != GroupBuyStatus.UnderWay)
            {
                throw new OrderException("当前团购状态不允许购买");
            }
            if ((info.StartDate > DateTime.Now) || (info.EndDate < DateTime.Now))
            {
                throw new OrderException("当前不在团购时间范围内");
            }
            int num = info.MaxCount - info.SoldCount;

            if (quantity > num)
            {
                throw new OrderException("剩余可购买团购数量不够");
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            int num = 0;

            if (!int.TryParse(this.Page.Request.QueryString["productId"].ToNullString(), out num))
            {
                int num2 = 0;
                int.TryParse(this.Page.Request.QueryString["countDownId"].ToNullString(), out num2);
                if (num2 > 0)
                {
                    CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(num2, 0);
                    if (countDownInfo != null)
                    {
                        num = countDownInfo.ProductId;
                    }
                }
                if (num <= 0)
                {
                    int num3 = 0;
                    int.TryParse(this.Page.Request.QueryString["groupBuyId"].ToNullString(), out num3);
                    if (num3 > 0)
                    {
                        GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(num3);
                        if (groupBuy != null)
                        {
                            num = groupBuy.ProductId;
                        }
                    }
                }
            }
            if (num > 0)
            {
                base.NavigateUrl = base.GetRouteUrl("ProductImages", new
                {
                    ProductId = num
                });
            }
            else
            {
                this.Visible = false;
            }
            base.Render(writer);
        }
Beispiel #12
0
        public static bool UpdateGroupBuy(GroupBuyInfo groupBuy)
        {
            bool flag;

            Globals.EntityCoding(groupBuy, true);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    GroupBuyDao dao = new GroupBuyDao();
                    if (!dao.UpdateGroupBuy(groupBuy, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!dao.DeleteGroupBuyCondition(groupBuy.GroupBuyId, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!dao.AddGroupBuyCondition(groupBuy.GroupBuyId, groupBuy.GroupBuyConditions, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
        public static ShoppingCartInfo GetGroupBuyShoppingCart(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
            {
                GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo(cartItemInfo.ProductId);
                if (productGroupBuyInfo == null)
                {
                    result = null;
                }
                else
                {
                    int     orderCount   = ProductBrowser.GetOrderCount(productGroupBuyInfo.GroupBuyId);
                    decimal currentPrice = ProductBrowser.GetCurrentPrice(productGroupBuyInfo.GroupBuyId, orderCount);
                    ShoppingCartItemInfo shoppingCartItemInfo = new ShoppingCartItemInfo();
                    shoppingCartItemInfo.SkuId       = cartItemInfo.SkuId;
                    shoppingCartItemInfo.ProductId   = cartItemInfo.ProductId;
                    shoppingCartItemInfo.SKU         = cartItemInfo.SKU;
                    shoppingCartItemInfo.Name        = cartItemInfo.Name;
                    shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = currentPrice);
                    shoppingCartItemInfo.SkuContent  = cartItemInfo.SkuContent;
                    ShoppingCartItemInfo arg_DC_0 = shoppingCartItemInfo;
                    shoppingCartItemInfo.ShippQuantity = buyAmount;
                    arg_DC_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 #14
0
        public bool UpdateGroupBuy(GroupBuyInfo groupBuy, DbTransaction dbTran)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_GroupBuy SET ProductId=@ProductId,NeedPrice=@NeedPrice,Count=@Count,Price=@Price,StartDate=@StartDate,EndDate=@EndDate,MaxCount=@MaxCount,Content=@Content,soldCount=@soldcout WHERE GroupBuyId=@GroupBuyId");

            this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuy.GroupBuyId);
            this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, groupBuy.ProductId);
            this.database.AddInParameter(sqlStringCommand, "NeedPrice", DbType.Currency, groupBuy.NeedPrice);
            this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, groupBuy.StartDate);
            this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, groupBuy.EndDate);
            this.database.AddInParameter(sqlStringCommand, "MaxCount", DbType.Int32, groupBuy.MaxCount);
            this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, groupBuy.Content);
            this.database.AddInParameter(sqlStringCommand, "soldcout", DbType.Int32, groupBuy.SoldCount);
            this.database.AddInParameter(sqlStringCommand, "Count", DbType.Int32, groupBuy.Count);
            this.database.AddInParameter(sqlStringCommand, "Price", DbType.Double, groupBuy.Price);
            if (dbTran != null)
            {
                return(this.database.ExecuteNonQuery(sqlStringCommand, dbTran) == 1);
            }
            return(this.database.ExecuteNonQuery(sqlStringCommand) == 1);
        }
Beispiel #15
0
        private void grdGroupBuyList_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            GroupBuyInfo groupBuy = SubsitePromoteHelper.GetGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value);

            if (groupBuy.Status != GroupBuyStatus.UnderWay)
            {
                if (groupBuy.Status != GroupBuyStatus.EndUntreated)
                {
                    if (SubsitePromoteHelper.DeleteGroupBuy((int)this.grdGroupBuyList.DataKeys[e.RowIndex].Value))
                    {
                        this.BindGroupBuy();
                        this.ShowMsg("成功删除了选择的团购活动", true);
                        return;
                    }
                    this.ShowMsg("删除失败", false);
                    return;
                }
            }
            this.ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false);
        }
Beispiel #16
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(GroupBuyQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                DbQueryResult groupBuyList = PromoteHelper.GetGroupBuyList(query);
                dataGridViewModel.rows  = DataHelper.DataTableToDictionary(groupBuyList.Data);
                dataGridViewModel.total = groupBuyList.TotalRecords;
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    GroupBuyInfo groupBuyInfo = row.ToObject <GroupBuyInfo>();
                    decimal      currentPrice = PromoteHelper.GetCurrentPrice(groupBuyInfo.GroupBuyId);
                    row.Add("CurrentPrice", currentPrice);
                    row.Add("StatusText", groupBuyInfo.StatusText);
                    row.Add("CanDelete", (groupBuyInfo.Status != GroupBuyStatus.UnderWay || !(groupBuyInfo.StartDate <= DateTime.Now) || !(groupBuyInfo.EndDate >= DateTime.Now)) && groupBuyInfo.Status != GroupBuyStatus.EndUntreated);
                }
            }
            return(dataGridViewModel);
        }
        private void ActivityBusiness()
        {
            CountDownInfo      countDownInfo = PromoteHelper.ActiveCountDownByProductId(this.productId, 0);
            GroupBuyInfo       groupBuyInfo  = PromoteHelper.ActiveGroupBuyByProductId(this.productId);
            ProductPreSaleInfo productPreSaleInfoByProductId = ProductPreSaleHelper.GetProductPreSaleInfoByProductId(this.productId);

            if (countDownInfo != null)
            {
                this.Page.Response.Redirect("/CountDownProductsDetails.aspx?countDownId=" + countDownInfo.CountDownId);
            }
            else if (groupBuyInfo != null)
            {
                this.Page.Response.Redirect("/GroupBuyProductDetails.aspx?groupBuyId=" + groupBuyInfo.GroupBuyId);
            }
            else if (productPreSaleInfoByProductId != null && productPreSaleInfoByProductId.PreSaleEndDate >= DateTime.Now)
            {
                this.Page.Response.Redirect("/PreSaleProductDetails.aspx?PreSaleId=" + productPreSaleInfoByProductId.PreSaleId);
            }
            else
            {
                int activityStartsImmediatelyAboutCountDown = PromoteHelper.GetActivityStartsImmediatelyAboutCountDown(this.productId);
                if (activityStartsImmediatelyAboutCountDown > 0)
                {
                    this.aCountDownUrl.Text        = "该商品即将参与抢购活动,     去看看";
                    this.aCountDownUrl.NavigateUrl = "/CountDownProductsDetails.aspx?countDownId=" + activityStartsImmediatelyAboutCountDown;
                    this.aCountDownUrl.Style.Add("color", "red");
                    this.aCountDownUrl.Visible = true;
                }
                else
                {
                    int activityStartsImmediatelyAboutGroupBuy = PromoteHelper.GetActivityStartsImmediatelyAboutGroupBuy(this.productId);
                    if (activityStartsImmediatelyAboutGroupBuy > 0)
                    {
                        this.aCountDownUrl.Text        = "该商品即将参与团购活动,     去看看";
                        this.aCountDownUrl.NavigateUrl = "/GroupBuyProductDetails.aspx?groupBuyId=" + activityStartsImmediatelyAboutGroupBuy;
                        this.aCountDownUrl.Style.Add("color", "red");
                        this.aCountDownUrl.Visible = true;
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(base.Request.QueryString["groupBuyId"], out groupBuyId))
     {
         base.GotoResourceNotFound();
     }
     else
     {
         btnUpdateGroupBuy.Click += new EventHandler(btnUpdateGroupBuy_Click);
         btnFail.Click           += new EventHandler(btnFail_Click);
         btnSuccess.Click        += new EventHandler(btnSuccess_Click);
         btnFinish.Click         += new EventHandler(btnFinish_Click);
         if (!base.IsPostBack)
         {
             dropGroupBuyProduct.DataBind();
             dropCategories.DataBind();
             GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(groupBuyId);
             if (PromoteHelper.GetOrderCount(groupBuyId) > 0)
             {
                 dropGroupBuyProduct.Enabled = false;
             }
             if (groupBuy == null)
             {
                 base.GotoResourceNotFound();
             }
             else
             {
                 if (groupBuy.Status == GroupBuyStatus.EndUntreated)
                 {
                     btnFail.Visible    = true;
                     btnSuccess.Visible = true;
                 }
                 if (groupBuy.Status == GroupBuyStatus.UnderWay)
                 {
                     btnFinish.Visible = true;
                 }
                 LoadGroupBuy(groupBuy);
             }
         }
     }
 }
Beispiel #19
0
        public static bool UpdateGroupBuy(GroupBuyInfo groupBuy)
        {
            bool flag;

            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    if (!SubsitePromotionsProvider.Instance().UpdateGroupBuy(groupBuy, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!SubsitePromotionsProvider.Instance().DeleteGroupBuyCondition(groupBuy.GroupBuyId, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!SubsitePromotionsProvider.Instance().AddGroupBuyCondition(groupBuy.GroupBuyId, groupBuy.GroupBuyConditions, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Beispiel #20
0
        public static ShoppingCartInfo GetGroupBuyShoppingCart(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
            {
                GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo(cartItemInfo.ProductId);
                if (productGroupBuyInfo == null || productGroupBuyInfo.StartDate > DateTime.Now || productGroupBuyInfo.Status != GroupBuyStatus.UnderWay)
                {
                    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 = productGroupBuyInfo.GroupBuyConditions[0].Price);
                    shoppingCartItemInfo.SkuContent  = cartItemInfo.SkuContent;
                    ShoppingCartItemInfo arg_ED_0 = shoppingCartItemInfo;
                    shoppingCartItemInfo.ShippQuantity = buyAmount;
                    arg_ED_0.Quantity                    = buyAmount;
                    shoppingCartItemInfo.Weight          = cartItemInfo.Weight;
                    shoppingCartItemInfo.ThumbnailUrl40  = cartItemInfo.ThumbnailUrl40;
                    shoppingCartItemInfo.ThumbnailUrl60  = cartItemInfo.ThumbnailUrl60;
                    shoppingCartItemInfo.ThumbnailUrl100 = cartItemInfo.ThumbnailUrl100;
                    shoppingCartItemInfo.IsfreeShipping  = cartItemInfo.IsfreeShipping;
                    shoppingCartInfo.LineItems.Add(shoppingCartItemInfo);
                    result = shoppingCartInfo;
                }
            }
            return(result);
        }
Beispiel #21
0
        private void LoadGroupBuy(GroupBuyInfo groupBuy)
        {
            TextBox textBox = this.txtPrice;
            decimal num     = groupBuy.Price;

            textBox.Text         = num.ToString("F");
            this.txtContent.Text = Globals.HtmlDecode(groupBuy.Content);
            TextBox textBox2 = this.txtMaxCount;
            int     num2     = groupBuy.MaxCount;

            textBox2.Text = num2.ToString();
            TextBox textBox3 = this.txtCount;

            num2          = groupBuy.Count;
            textBox3.Text = num2.ToString();
            TextBox textBox4 = this.txtNeedPrice;

            num           = groupBuy.NeedPrice;
            textBox4.Text = num.ToString("F");
            this.calendarEndDate.SelectedDate   = groupBuy.EndDate;
            this.calendarStartDate.SelectedDate = groupBuy.StartDate;
        }
Beispiel #22
0
        OrderInfo GetOrderInfo(ShoppingCartInfo shoppingCartInfo)
        {
            OrderInfo orderInfo = ShoppingProcessor.ConvertShoppingCartToOrder(shoppingCartInfo, isGroupBuy, isCountDown, isSignBuy);

            if (orderInfo == null)
            {
                return(null);
            }
            if (isGroupBuy)
            {
                GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo(shoppingCartInfo.LineItems[productSku].ProductId);
                orderInfo.GroupBuyId = productGroupBuyInfo.GroupBuyId;
                orderInfo.NeedPrice  = productGroupBuyInfo.NeedPrice;
            }
            orderInfo.OrderId   = 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(txtMessage.Text);
            orderInfo.OrderStatus  = OrderStatus.WaitBuyerPay;
            orderInfo.RefundStatus = RefundStatus.None;
            FillOrderCoupon(orderInfo);
            FillOrderShippingMode(orderInfo, shoppingCartInfo);
            FillOrderOptions(orderInfo);
            FillOrderPaymentMode(orderInfo);
            return(orderInfo);
        }
Beispiel #23
0
        public GroupBuyInfo GetGroupBuy(int groupBuyId)
        {
            GroupBuyInfo groupBuyInfo     = null;
            DbCommand    sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM vw_Ecshop_GroupBuy WHERE GroupBuyId=@GroupBuyId;SELECT * FROM Ecshop_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId");

            this.database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    groupBuyInfo = DataMapper.PopulateGroupBuy(dataReader);
                }
                dataReader.NextResult();
                while (dataReader.Read())
                {
                    GropBuyConditionInfo gropBuyConditionInfo = new GropBuyConditionInfo();
                    gropBuyConditionInfo.Count = (int)dataReader["Count"];
                    gropBuyConditionInfo.Price = (decimal)dataReader["Price"];
                    groupBuyInfo.GroupBuyConditions.Add(gropBuyConditionInfo);
                }
            }
            return(groupBuyInfo);
        }
Beispiel #24
0
        public override GroupBuyInfo GetGroupBuy(int groupBuyId)
        {
            GroupBuyInfo info             = null;
            DbCommand    sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_GroupBuy WHERE GroupBuyId=@GroupBuyId;SELECT * FROM Hishop_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId");

            database.AddInParameter(sqlStringCommand, "GroupBuyId", DbType.Int32, groupBuyId);
            using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateGroupBuy(reader);
                }
                reader.NextResult();
                while (reader.Read())
                {
                    GropBuyConditionInfo item = new GropBuyConditionInfo();
                    item.Count = (int)reader["Count"];
                    item.Price = (decimal)reader["Price"];
                    info.GroupBuyConditions.Add(item);
                }
            }
            return(info);
        }
Beispiel #25
0
        public static bool AddGroupBuy(GroupBuyInfo groupBuy)
        {
            bool flag;

            Globals.EntityCoding(groupBuy, true);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    int groupBuyId = PromotionsProvider.Instance().AddGroupBuy(groupBuy, dbTran);
                    if (groupBuyId <= 0)
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    if (!PromotionsProvider.Instance().AddGroupBuyCondition(groupBuyId, groupBuy.GroupBuyConditions, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Beispiel #26
0
        public void Delete(HttpContext context)
        {
            string text = context.Request["GroupBuyIds"];

            if (string.IsNullOrWhiteSpace(text))
            {
                throw new HidistroAshxException("错误的活动编号");
            }
            int[] array = (from d in text.Split(',')
                           select int.Parse(d)).ToArray();
            int num  = 0;
            int num2 = array.Count();

            int[] array2 = array;
            foreach (int groupBuyId in array2)
            {
                GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(groupBuyId);
                if ((groupBuy.Status == GroupBuyStatus.UnderWay && groupBuy.StartDate <= DateTime.Now && groupBuy.EndDate >= DateTime.Now) || groupBuy.Status == GroupBuyStatus.EndUntreated)
                {
                    if (num2 == 1)
                    {
                        throw new HidistroAshxException("团购活动正在进行中或结束未处理,不允许删除!");
                    }
                }
                else
                {
                    num++;
                    PromoteHelper.DeleteGroupBuy(groupBuyId);
                }
            }
            if (num > 0)
            {
                base.ReturnSuccessResult(context, $"成功删除{num}条团购活动!", 0, true);
                return;
            }
            throw new HidistroAshxException("选择的团购活动暂不可删除!");
        }
Beispiel #27
0
        public override GroupBuyInfo GetGroupBuy(int groupBuyId)
        {
            GroupBuyInfo groupBuyInfo = null;

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_GroupBuy WHERE GroupBuyId=@GroupBuyId AND DistributorUserId=@DistributorUserId;SELECT * FROM distro_GroupBuyCondition WHERE GroupBuyId=@GroupBuyId AND DistributorUserId=@DistributorUserId");
            this.database.AddInParameter(sqlStringCommand, "GroupBuyId", System.Data.DbType.Int32, groupBuyId);
            this.database.AddInParameter(sqlStringCommand, "DistributorUserId", System.Data.DbType.Int32, HiContext.Current.SiteSettings.UserId.Value);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    groupBuyInfo = DataMapper.PopulateGroupBuy(dataReader);
                }
                dataReader.NextResult();
                while (dataReader.Read())
                {
                    GropBuyConditionInfo gropBuyConditionInfo = new GropBuyConditionInfo();
                    gropBuyConditionInfo.Count = (int)dataReader["Count"];
                    gropBuyConditionInfo.Price = (decimal)dataReader["Price"];
                    groupBuyInfo.GroupBuyConditions.Add(gropBuyConditionInfo);
                }
            }
            return(groupBuyInfo);
        }
Beispiel #28
0
        public static ShoppingCartInfo GetGroupBuyShoppingCart(int groupbuyId, string productSkuId, int buyAmount)
        {
            ShoppingCartItemInfo shoppingCartItemInfo;
            ShoppingCartInfo     info          = new ShoppingCartInfo();
            MemberInfo           currentMember = MemberProcessor.GetCurrentMember();
            ShoppingCartItemInfo info3         = new ShoppingCartDao().GetCartItemInfo(currentMember, productSkuId, buyAmount);

            if (info3 == null)
            {
                return(null);
            }
            GroupBuyInfo groupBuy = GroupBuyBrowser.GetGroupBuy(groupbuyId);

            if (((groupBuy == null) || (groupBuy.StartDate > DateTime.Now)) || (groupBuy.Status != GroupBuyStatus.UnderWay))
            {
                return(null);
            }
            int     count = groupBuy.Count;
            decimal price = groupBuy.Price;

            shoppingCartItemInfo                 = new ShoppingCartItemInfo();
            shoppingCartItemInfo.SkuId           = info3.SkuId;
            shoppingCartItemInfo.ProductId       = info3.ProductId;
            shoppingCartItemInfo.SKU             = info3.SKU;
            shoppingCartItemInfo.Name            = info3.Name;
            shoppingCartItemInfo.MemberPrice     = shoppingCartItemInfo.AdjustedPrice = price;
            shoppingCartItemInfo.SkuContent      = info3.SkuContent;
            shoppingCartItemInfo.Quantity        = shoppingCartItemInfo.ShippQuantity = buyAmount;
            shoppingCartItemInfo.Weight          = info3.Weight;
            shoppingCartItemInfo.ThumbnailUrl40  = info3.ThumbnailUrl40;
            shoppingCartItemInfo.ThumbnailUrl60  = info3.ThumbnailUrl60;
            shoppingCartItemInfo.ThumbnailUrl100 = info3.ThumbnailUrl100;

            info.LineItems.Add(shoppingCartItemInfo);
            return(info);
        }
Beispiel #29
0
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "Skin-ServiceProductSubmitOrder.html";
            }
            base.OnInit(e);
            string urlToEncode = "";

            this.from          = this.Page.Request.QueryString["from"].ToNullString().ToLower();
            this.productSku    = Globals.UrlDecode(this.Page.Request.QueryString["productSku"].ToNullString());
            this.buyAmount     = this.Page.Request.QueryString["buyAmount"].ToInt(0);
            this.storeId       = this.Page.Request.QueryString["StoreId"].ToInt(0);
            this.chooseStoreId = this.Page.Request.QueryString["ChooseStoreId"].ToInt(0);
            if (this.from == "groupbuy")
            {
                this.isGroupBuy = true;
            }
            else if (this.from == "countdown")
            {
                this.isCountDown = true;
            }
            else if (this.from == "fightgroup")
            {
                this.isFightGroup = true;
            }
            else
            {
                if (this.from == "presale")
                {
                    this.PresaleId  = this.Page.Request.QueryString["PresaleId"].ToInt(0);
                    this.productSku = DataHelper.CleanSearchString(this.productSku);
                    if (this.CheckPresaleInfo())
                    {
                        this.isPreSale = true;
                        goto IL_01cd;
                    }
                    return;
                }
                this.from = "serviceproduct";
            }
            goto IL_01cd;
IL_01cd:
            if (this.storeId == 0 && !HiContext.Current.SiteSettings.OpenMultStore)
            {
                this.cart = ShoppingCartProcessor.GetShoppingCart(this.from, this.productSku, this.buyAmount, 0, true, -1, this.Page.Request["fightGroupActivityId"].ToInt(0));
            }
            else
            {
                this.cart = ShoppingCartProcessor.GetShoppingCart(this.from, this.productSku, this.buyAmount, 0, true, this.storeId, this.Page.Request["fightGroupActivityId"].ToInt(0));
            }
            if (this.cart == null)
            {
                string msg = "购物车无任何商品!";
                this.hasError = true;
                this.ShowWapMessage(msg, "default.aspx");
            }
            else
            {
                if (this.isGroupBuy)
                {
                    this.groupbuyInfo = TradeHelper.GetProductGroupBuyInfo(this.cart.LineItems[0].ProductId, this.buyAmount, out urlToEncode);
                    if (this.groupbuyInfo == null)
                    {
                        this.hasError = true;
                        this.ShowWapMessage(Globals.UrlEncode(urlToEncode), "default.aspx");
                        return;
                    }
                }
                if (this.isCountDown)
                {
                    this.countdownInfo = TradeHelper.ProductExistsCountDown(this.cart.LineItems[0].ProductId, "", this.storeId);
                    if (this.countdownInfo == null)
                    {
                        this.hasError = true;
                        this.ShowWapMessage("该商品未进行抢购活动,或者活动已结束", "Default.aspx");
                        return;
                    }
                    if (!StoreActivityHelper.JoinActivity(this.countdownInfo.CountDownId, 2, this.storeId, this.countdownInfo.StoreType))
                    {
                        this.hasError = true;
                        this.ShowWapMessage("该门店未参与此抢购活动", "Default.aspx");
                        return;
                    }
                    this.countdownInfo = TradeHelper.CheckUserCountDown(this.cart.LineItems[0].ProductId, this.countdownInfo.CountDownId, this.cart.LineItems[0].SkuId, HiContext.Current.UserId, this.buyAmount, "", out urlToEncode, this.storeId);
                    if (this.countdownInfo == null)
                    {
                        this.ShowWapMessage(Globals.UrlEncode(urlToEncode), "Default.aspx");
                        return;
                    }
                }
                if (this.isFightGroup)
                {
                    this.fightGroupActivitiyInfo = TradeHelper.GetFightGroupActivitieInfo(this.Page.Request["fightGroupActivityId"].ToInt(0));
                    if (this.fightGroupActivitiyInfo == null)
                    {
                        this.hasError = true;
                        this.ShowWapMessage("拼团活动不存在", "Default.aspx");
                    }
                    else
                    {
                        int num = this.Page.Request["fightGroupId"].ToInt(0);
                        this.fightGroupInfo = VShopHelper.GetFightGroup(num);
                        if (this.fightGroupInfo == null && num != 0)
                        {
                            this.hasError = true;
                            this.ShowWapMessage("拼团活动不存在", "Default.aspx");
                        }
                    }
                }
            }
        }
Beispiel #30
0
        private void UserPayOrder(OrderInfo order)
        {
            ErrorLog.Write(string.Format("支付宝App支付回调,校验成功,开始更新订单{0}状态", this.Order.OrderId));

            if (order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                base.Response.Write("success");
                return;
            }

            if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                base.Response.Write("success");
                return;
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            if (this.Order.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    base.Response.Write("groupbuyalreadyfinished");
                    return;
                }
                num2 = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                num3 = this.Order.GetGroupBuyOerderNumber();
                num  = groupBuy.MaxCount;
                if (num < num2 + num3)
                {
                    base.Response.Write("exceedordermax");
                    return;
                }
            }

            if (Order.OrderStatus == OrderStatus.WaitBuyerPay)
            {
                //如果需要拆单
                if (TradeHelper.CheckIsUnpack(this.Order.OrderId))
                {
                    ErrorLog.Write(string.Format("支付宝App支付,拆单,原订单{0}", this.Order.OrderId));
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, 1))
                    {
                        //OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2);
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                        if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                        {
                            IUser user = Users.GetUser(this.Order.UserId);
                            if (user != null && user.UserRole == UserRole.Member)
                            {
                                Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                            }
                        }
                        this.Order.OnPayment();
                        base.Response.Write("success");
                    }
                }
                else if (Order.OrderType == (int)OrderType.WillMerge)//合并单据
                {
                    bool b    = ShoppingProcessor.mergeOrder(this.Order);
                    int  flag = 0;
                    if (b)
                    {
                        flag = 2;
                    }
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, flag))
                    {
                        //OrderHelper.SetOrderPayStatus(orderId, 2);
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                        if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                        {
                            IUser user = Users.GetUser(this.Order.UserId);
                            if (user != null && user.UserRole == UserRole.Member)
                            {
                                Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                            }
                        }
                        this.Order.OnPayment();
                        base.Response.Write("success");
                    }
                }
                else
                {
                    ErrorLog.Write(string.Format("支付宝App支付,正常单据,原订单{0}", this.Order.OrderId));
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
                    {
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);

                        TradeHelper.SaveDebitNote(new DebitNoteInfo
                        {
                            NoteId   = Globals.GetGenerateId(),
                            OrderId  = this.Order.OrderId,
                            Operator = this.Order.Username,
                            Remark   = "客户订单在线支付成功"
                        });
                        if (this.Order.GroupBuyId > 0 && num == num2 + num3)
                        {
                            TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                        }
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                        if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                        {
                            IUser user = Users.GetUser(this.Order.UserId);
                            if (user != null && user.UserRole == UserRole.Member)
                            {
                                Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                            }
                        }
                        this.Order.OnPayment();
                        base.Response.Write("success");
                    }
                }
            }
            else
            {
                ErrorLog.Write(string.Format("支付宝App支付,当前状态不支持付款,原订单{0},订单状态{1}", this.Order.OrderId, (int)this.Order.OrderStatus));
                base.Response.Write("fail");
            }

            //if (order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(order, false))
            //{
            //    order.OnPayment();
            //    base.Response.Write("success");
            //}
        }