protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int id = RequestHelper.GetQueryString <int>("Id"); if (id != int.MinValue) { CheckAdminPower("ReadPointProduct", PowerCheckType.Single); pointProduct = PointProductBLL.Read(id); Name.Text = pointProduct.Name; SubTitle.Text = pointProduct.SubTitle; Point.Text = pointProduct.Point.ToString(); TotalCount.Text = pointProduct.TotalStorageCount.ToString(); BeginDate.Text = pointProduct.BeginDate.ToString("yyyy-MM-dd"); EndDate.Text = pointProduct.EndDate.ToString("yyyy-MM-dd"); MarketPrice.Text = pointProduct.MarketPrice.ToString(); Photo.Text = pointProduct.Photo; Introduction.Value = pointProduct.Introduction1; Introduction_Mobile.Value = pointProduct.Introduction1_Mobile; productPhotoList = ProductPhotoBLL.ReadList(pointProduct.Id, 0); } } }
protected override void PageLoad() { base.PageLoad(); string action = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Action")); if (action == "Submit") { this.Submit(); } if (action == "CheckPoint") { this.CheckPoint(); } int id = RequestHelper.GetQueryString <int>("Id"); if (base.UserId == 0) { string redirectUrl = string.IsNullOrEmpty(isMobile) ? "/user/login.html?RedirectUrl=/gift/exchange/" + id.ToString() + ".html" : "/mobile/login.html?RedirectUrl=/mobile/gift/exchange/" + id.ToString() + ".html"; ResponseHelper.Redirect(redirectUrl); ResponseHelper.End(); } CurrentUser = UserBLL.Read(base.UserId); Gift = PointProductBLL.Read(id); userPoint = UserAccountRecordBLL.SumPoint(base.UserId); singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass(); singleUnlimitClass.ClassID = "|1" + CurrentUser.RegionId; Title = Gift.Name + " - 奖品兑换"; }
public void Update(PointProductInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"UPDATE PointProduct SET Name = @Name, SubTitle = @SubTitle, MarketPrice = @MarketPrice, Point = @Point, Photo = @Photo, Keywords = @Keywords, Summary = @Summary, Introduction1 = @Introduction1, Introduction1_Mobile = @Introduction1_Mobile, IsSale = @IsSale, ViewCount = @ViewCount, TotalStorageCount = @TotalStorageCount, SendCount = @SendCount, AddDate = @AddDate, OrderId = @OrderId, BeginDate = @BeginDate, EndDate = @EndDate where Id=@Id"; conn.Execute(sql, entity); } }
public int Add(PointProductInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"INSERT INTO PointProduct( Name,SubTitle,MarketPrice,Point,Photo,Keywords,Summary,Introduction1,Introduction1_Mobile,IsSale,ViewCount,TotalStorageCount,SendCount,AddDate,OrderId,BeginDate,EndDate) VALUES(@Name,@SubTitle,@MarketPrice,@Point,@Photo,@Keywords,@Summary,@Introduction1,@Introduction1_Mobile,@IsSale,@ViewCount,@TotalStorageCount,@SendCount,@AddDate,@OrderId,@BeginDate,@EndDate); select SCOPE_IDENTITY()"; return(conn.Query <int>(sql, entity).Single()); } }
protected override void PageLoad() { base.PageLoad(); int id = RequestHelper.GetQueryString <int>("Id"); Gift = PointProductBLL.Read(id); //产品图片 ProductPhotoList.Add(new ProductPhotoInfo { Name = Gift.Name, ImageUrl = Gift.Photo }); ProductPhotoList.AddRange(ProductPhotoBLL.ReadList(Gift.Id, 0)); }
protected void SubmitButton_Click(object sender, EventArgs e) { int productId = RequestHelper.GetQueryString <int>("Id"); PointProductInfo pointProductSubmit = PointProductBLL.Read(productId); pointProductSubmit.Id = productId; pointProductSubmit.Name = Name.Text; pointProductSubmit.SubTitle = SubTitle.Text; pointProductSubmit.Point = Convert.ToInt32(Point.Text); pointProductSubmit.TotalStorageCount = Convert.ToInt32(TotalCount.Text); pointProductSubmit.BeginDate = Convert.ToDateTime(BeginDate.Text); pointProductSubmit.EndDate = Convert.ToDateTime(EndDate.Text); pointProductSubmit.MarketPrice = Convert.ToDecimal(MarketPrice.Text); pointProductSubmit.Photo = Photo.Text; pointProductSubmit.Introduction1 = Introduction.Value; pointProductSubmit.Introduction1_Mobile = Introduction_Mobile.Value; pointProductSubmit.IsSale = RequestHelper.GetForm <int>("IsSale"); pointProductSubmit.AddDate = RequestHelper.DateNow; string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (pointProductSubmit.Id <= 0) { CheckAdminPower("AddPointProduct", PowerCheckType.Single); int id = PointProductBLL.Add(pointProductSubmit); if (id > 0) { AddProductPhoto(id); } AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("PointProduct"), id); } else { CheckAdminPower("UpdatePointProduct", PowerCheckType.Single); ProductPhotoBLL.DeleteList(productId, 0); AddProductPhoto(productId); PointProductBLL.Update(pointProductSubmit); AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("PointProduct"), pointProductSubmit.Id); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); } ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl); }
protected override void PageLoad() { base.PageLoad(); int id = RequestHelper.GetQueryString <int>("Id"); gift = PointProductBLL.Read(id); //如果暂未开始或者已经结束 if (gift.EndDate.Date < DateTime.Now.Date || gift.BeginDate.Date > DateTime.Now.Date) { ResponseHelper.Redirect("/pointproduct.html"); } //产品图片 photoList.Add(new ProductPhotoInfo { Name = gift.Name, ImageUrl = gift.Photo }); photoList.AddRange(ProductPhotoBLL.ReadList(gift.Id, 0)); Title = gift.Name + " - 积分商品兑换"; }
protected override void PageLoad() { base.PageLoad(); string action = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Action")); if (action == "Submit") { this.Submit(); } if (action == "CheckPoint") { this.CheckPoint(); } int id = RequestHelper.GetQueryString <int>("Id"); if (base.UserId <= 0) { ResponseHelper.Redirect("/user/login.html?RedirectUrl=/pointexchange/" + id.ToString() + ".html"); ResponseHelper.End(); } gift = PointProductBLL.Read(id); if (gift.EndDate.Date < DateTime.Now.Date) { ResponseHelper.Redirect("/pointproduct.html"); } var currentUser = UserBLL.Read(base.UserId); userPoint = UserAccountRecordBLL.SumPoint(base.UserId); singleUnlimitClass.DataSource = RegionBLL.ReadRegionUnlimitClass(); singleUnlimitClass.ClassID = base.UserId > 0? currentUser.RegionId:"|1|"; Title = gift.Name + " - 积分商品兑换"; }
protected void Submit() { string userName = base.UserName; string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass(); //检测积分 int id = RequestHelper.GetForm <int>("updateId"); if (id < 1) { ResponseHelper.Write("error|无效的请求"); ResponseHelper.End(); } if (singleUnlimitClass.ClassID.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Length < 3) { ResponseHelper.Write("error|请填写完整的地区信息"); ResponseHelper.End(); ResponseHelper.End(); } var pointLeft = UserAccountRecordBLL.SumPoint(base.UserId); Gift = PointProductBLL.Read(id); if (Gift.Point > pointLeft) { ResponseHelper.Write("error|您当前的积分不足以兑取该礼品"); ResponseHelper.End(); } //库存 int num = RequestHelper.GetForm <int>("num"); if (num > (Gift.TotalStorageCount - Gift.SendCount)) { ResponseHelper.Write("error|该礼品库存不足"); ResponseHelper.End(); } //添加订单 OrderInfo order = new OrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.IsActivity = (int)BoolType.True; order.OrderStatus = (int)OrderStatus.WaitCheck; order.OrderNote = "积分兑换奖品"; order.ProductMoney = 0; order.Balance = 0; order.FavorableMoney = 0; order.OtherMoney = 0; order.CouponMoney = 0; order.Consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("username")); order.RegionId = singleUnlimitClass.ClassID; order.Address = StringHelper.AddSafe(RequestHelper.GetForm <string>("address")); order.ZipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("zipcode")); order.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("tel")); order.Email = userEmail; order.Mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("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 = RequestHelper.DateNow;; 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 = ClientHelper.IP; order.UserId = base.UserId; order.UserName = userName; order.ActivityPoint = Gift.Point * num; int orderID = OrderBLL.Add(order); //添加订单详细 OrderDetailInfo orderDetail = new OrderDetailInfo(); orderDetail.OrderId = orderID; orderDetail.ProductId = Gift.Id; orderDetail.ProductName = Gift.Name; orderDetail.ProductWeight = Gift.Weight; orderDetail.SendPoint = 0; orderDetail.ProductPrice = 0; orderDetail.ActivityPoint = Gift.Point; orderDetail.BuyCount = num; orderDetail.ParentId = 0; orderDetail.RandNumber = string.Empty; orderDetail.GiftPackId = 0; OrderDetailBLL.Add(orderDetail); //积分记录 var accountRecord = new UserAccountRecordInfo { Money = 0, Point = -Gift.Point * num, Date = DateTime.Now, IP = ClientHelper.IP, Note = "兑换礼品-" + Gift.Name, UserId = base.UserId, UserName = base.UserName }; UserAccountRecordBLL.Add(accountRecord); //更新商品的已兑换数量 Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("SendCount", Gift.SendCount + num); PointProductBLL.UpdatePart(PointProductInfo.TABLENAME, dict, Gift.Id); ResponseHelper.Write("ok|" + orderID); ResponseHelper.End(); }
protected void Submit() { if (base.UserId <= 0) { ResponseHelper.Write("error|还未登录"); ResponseHelper.End(); } int pointLeft = UserAccountRecordBLL.SumPoint(base.UserId); string userName = base.UserName; string userEmail = CookiesHelper.ReadCookieValue("UserEmail"); //检测积分 int id = RequestHelper.GetForm <int>("updateId"); if (id < 1) { ResponseHelper.Write("error|无效的请求"); ResponseHelper.End(); } gift = PointProductBLL.Read(id); if (gift.IsSale != (int)BoolType.True) { ResponseHelper.Write("error|该商品已下架"); ResponseHelper.End(); } if (gift.Point > pointLeft) { ResponseHelper.Write("error|您当前的积分不足以兑取该商品"); ResponseHelper.End(); } if (gift.EndDate.Date < DateTime.Now.Date) { ResponseHelper.Write("error|该商品已过有效兑取时间"); ResponseHelper.End(); } //库存 if (gift.TotalStorageCount - gift.SendCount < 1) { ResponseHelper.Write("error|该商品库存不足"); ResponseHelper.End(); } //添加订单 var order = new PointProductOrderInfo(); order.OrderNumber = ShopCommon.CreateOrderNumber(); order.OrderStatus = (int)PointProductOrderStatus.Shipping; order.Point = gift.Point; order.ProductId = gift.Id; order.ProductName = gift.Name; order.BuyCount = 1; order.Consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("username")); SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass(); order.RegionId = singleUnlimitClass.ClassID; order.Address = StringHelper.AddSafe(RequestHelper.GetForm <string>("address")); order.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("mobile")); order.AddDate = DateTime.Now; order.IP = ClientHelper.IP; order.UserId = base.UserId; order.UserName = base.UserName; order.Id = PointProductOrderBLL.Add(order); if (order.Id > 0) { //扣减积分 UserAccountRecordBLL.Add(new UserAccountRecordInfo { RecordType = (int)AccountRecordType.Point, Money = 0, Point = -order.Point, Date = DateTime.Now, IP = ClientHelper.IP, Note = "兑取商品:" + order.ProductName + " 订单号:" + order.OrderNumber, UserId = order.UserId, UserName = order.UserName }); //扣减库存 PointProductBLL.ChangeSendCount(order.ProductId, ChangeAction.Plus); } ResponseHelper.Write("ok|" + order.Id); ResponseHelper.End(); }
public static void Update(PointProductInfo entity) { dal.Update(entity); }
public static int Add(PointProductInfo entity) { return(dal.Add(entity)); }