/// <summary> /// 提交按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitButton_Click(object sender, EventArgs e) { //读取用户信息 userID = Cookies.User.GetUserID(true); string userName = Cookies.User.GetUserName(false); string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); //添加团购记录 int id = RequestHelper.GetQueryString <int>("ID"); groupBuy = GroupBuyBLL.ReadGroupBuy(id); UserGroupBuyInfo userGroupBuy = new UserGroupBuyInfo(); userGroupBuy.GroupBuyID = id; userGroupBuy.Date = RequestHelper.DateNow; userGroupBuy.IP = ClientHelper.IP; userGroupBuy.BuyCount = RequestHelper.GetForm <int>("BuyCount"); userGroupBuy.OrderID = 0; userGroupBuy.UserID = userID; userGroupBuy.UserName = userName; userGroupBuy.Consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee")); userGroupBuy.RegionID = RegionID.ClassID; userGroupBuy.Address = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address")); userGroupBuy.ZipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode")); userGroupBuy.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel")); userGroupBuy.Email = userEmail; userGroupBuy.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile")); UserGroupBuyBLL.AddUserGroupBuy(userGroupBuy); UserAccountRecordBLL.AddUserAccountRecord(-groupBuy.Price * userGroupBuy.BuyCount, 0, "参加团购活动:" + groupBuy.Name, userID, userName); ScriptHelper.Alert("购买成功!", "GroupBuyDetail.aspx?ID=" + userGroupBuy.GroupBuyID); }
/// <summary> /// 删除按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteButton_Click(object sender, EventArgs e) { CheckAdminPower("DeleteUserGroupBuy", PowerCheckType.Single); string deleteID = RequestHelper.GetIntsForm("SelectID"); if (deleteID != string.Empty) { UserGroupBuyBLL.DeleteUserGroupBuy(deleteID); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("UserGroupBuy"), deleteID); ScriptHelper.Alert(ShopLanguage.ReadLanguage("DeleteOK"), RequestHelper.RawUrl); } }
/// <summary> /// 删除多条团购数据 /// </summary> /// <param name="strID">团购的主键值,以,号分隔</param> public static void DeleteGroupBuy(string strID) { if (strID == string.Empty) { return; } UploadBLL.DeleteUploadByRecordID(TableID, strID); UserGroupBuyBLL.DeleteUserGroupBuyByGroupBuyID(strID); string sql = "DELETE FROM " + GroupBuyAccessHelper.TablePrefix + "GroupBuy WHERE [ID] IN(" + strID + ")"; GroupBuyAccessHelper.ExecuteNonQuery(sql); }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadUserGroupBuy", PowerCheckType.Single); int groupBuyID = RequestHelper.GetQueryString <int>("GroupBuyID"); groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID); BindControl(UserGroupBuyBLL.ReadUserGroupBuyList(groupBuyID, CurrentPage, PageSize, ref Count), RecordList, MyPager); if (groupBuy.MinCount <= UserGroupBuyBLL.ReadUserGroupBuyCount(groupBuyID)) { isCreateOrder = true; } } }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { 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; userGroupBuyList = UserGroupBuyBLL.ReadUserGroupBuyList(id); foreach (UserGroupBuyInfo userGroupBuy in userGroupBuyList) { buyCount += userGroupBuy.BuyCount; } product = ProductBLL.ReadProduct(groupBuy.ProductID); Head.Title = product.Name + " - 商品团购"; }
/// <summary> /// 取消活动,退还用户余额 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void CancleButton_Click(object sender, EventArgs e) { int groupBuyID = RequestHelper.GetQueryString <int>("GroupBuyID"); groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID); List <UserGroupBuyInfo> userGroupBuyList = UserGroupBuyBLL.ReadUserGroupBuyList(groupBuyID); foreach (UserGroupBuyInfo userGroupBuy in userGroupBuyList) { if (userGroupBuy.OrderID == 0) { UserGroupBuyBLL.UpdateUserGroupBuy(userGroupBuy.ID, -1); UserAccountRecordBLL.AddUserAccountRecord(groupBuy.Price * userGroupBuy.BuyCount, 0, "退还团购活动支付余额:" + groupBuy.Name, userGroupBuy.UserID, userGroupBuy.UserName); } } ScriptHelper.Alert("处理成功", RequestHelper.RawUrl); }
protected void Page_Load(object sender, EventArgs e) { int currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 10; int count = 0; groupBuyList = GroupBuyBLL.ReadGroupBuyList(currentPage, pageSize, ref count); MyPager.CurrentPage = currentPage; MyPager.PageSize = pageSize; MyPager.Count = count; string productIDList = string.Empty; string idList = string.Empty; foreach (GroupBuyInfo groupBuy in groupBuyList) { if (productIDList == string.Empty) { productIDList = groupBuy.ProductID.ToString(); idList = groupBuy.ID.ToString(); } else { productIDList += "," + groupBuy.ProductID.ToString(); idList += "," + groupBuy.ID.ToString(); } } //读取商品 if (productIDList != string.Empty) { ProductSearchInfo productSearch = new ProductSearchInfo(); productSearch.InProductID = productIDList; productList = ProductBLL.SearchProductList(productSearch); } //读取购买人数 if (idList != string.Empty) { dicCount = UserGroupBuyBLL.ReadUserGroupBuyCount(idList); } }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int id = RequestHelper.GetQueryString <int>("ID"); userID = Cookies.User.GetUserID(true); decimal moneyLeft = UserBLL.ReadUserMore(userID).MoneyLeft; if (userID == 0) { ScriptHelper.Alert("请先登录", "/User/Login.aspx?RedirectUrl=/Plugins/Activity/GroupBuy/GroupBuyAdd.aspx?ID=" + id.ToString()); } groupBuy = GroupBuyBLL.ReadGroupBuy(id); if (moneyLeft < groupBuy.Price) { ScriptHelper.Alert("您账户余额不够该团购活动商品价格,请先充值", "/User/UserRecharge.aspx"); } if (UserGroupBuyBLL.ReadUserGroupBuyByUser(id, userID).ID > 0) { ScriptHelper.Alert("您已经参加该活动了,请不要重复参加"); } if (groupBuy.StartDate > DateTime.Now) { ScriptHelper.Alert("该团购活动未开始,不能购买"); } if (groupBuy.EndDate < DateTime.Now) { ScriptHelper.Alert("该团购活动已经结束,不能购买"); } buyCount = UserGroupBuyBLL.ReadUserGroupBuyCount(id); product = ProductBLL.ReadProduct(groupBuy.ProductID); RegionID.DataSource = RegionBLL.ReadRegionUnlimitClass(); UserInfo user = UserBLL.ReadUser(userID); Consignee.Text = user.UserName; Tel.Text = user.Tel; Mobile.Text = user.Mobile; Address.Text = user.Address; RegionID.ClassID = user.RegionID; Head.Title = "确认商品团购"; } }
/// <summary> /// 全部生成订单按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void CreateOrderButton_Click(object sender, EventArgs e) { int groupBuyID = RequestHelper.GetQueryString <int>("GroupBuyID"); groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID); ProductInfo product = ProductBLL.ReadProduct(groupBuy.ProductID); List <UserGroupBuyInfo> userGroupBuyList = UserGroupBuyBLL.ReadUserGroupBuyList(groupBuyID); foreach (UserGroupBuyInfo userGroupBuy in userGroupBuyList) { if (userGroupBuy.OrderID == 0) { decimal totalPrice = groupBuy.Price * userGroupBuy.BuyCount; //添加订单 OrderInfo order = new OrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.IsActivity = (int)BoolType.True; order.OrderStatus = (int)OrderStatus.WaitCheck; order.OrderNote = "团购活动:" + groupBuy.Name; order.ProductMoney = totalPrice; order.Balance = totalPrice; order.FavorableMoney = 0; order.OtherMoney = 0; order.CouponMoney = 0; order.Consignee = userGroupBuy.Consignee; order.RegionID = userGroupBuy.RegionID; order.Address = userGroupBuy.Address; order.ZipCode = userGroupBuy.ZipCode; order.Tel = userGroupBuy.Tel; order.Email = userGroupBuy.Email; order.Mobile = userGroupBuy.Mobile; order.ShippingID = 0; order.ShippingDate = RequestHelper.DateNow; order.ShippingNumber = string.Empty; order.ShippingMoney = 0; order.PayKey = string.Empty; order.PayName = string.Empty; order.PayDate = userGroupBuy.Date;; order.IsRefund = (int)BoolType.False; order.FavorableActivityID = 0; order.GiftID = 0; order.InvoiceTitle = string.Empty; order.InvoiceContent = string.Empty; order.UserMessage = string.Empty; order.AddDate = RequestHelper.DateNow; order.IP = userGroupBuy.IP; order.UserID = userGroupBuy.UserID; order.UserName = userGroupBuy.UserName; int orderID = OrderBLL.AddOrder(order); //添加订单详细 OrderDetailInfo orderDetail = new OrderDetailInfo(); orderDetail.OrderID = orderID; orderDetail.ProductID = product.ID; orderDetail.ProductName = product.Name; orderDetail.ProductWeight = product.Weight; orderDetail.SendPoint = 0; orderDetail.ProductPrice = groupBuy.Price; orderDetail.BuyCount = userGroupBuy.BuyCount; orderDetail.FatherID = 0; orderDetail.RandNumber = string.Empty; orderDetail.GiftPackID = 0; OrderDetailBLL.AddOrderDetail(orderDetail); //更新订单 ID UserGroupBuyBLL.UpdateUserGroupBuy(userGroupBuy.ID, orderID); //更改产品库存订单数量 ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus); } } ScriptHelper.Alert("处理成功", RequestHelper.RawUrl); }