public void PointChangeCoupon() { string s = this.context.Request["couponId"]; string s2 = this.context.Request["needPoints"]; int num = 0; int num2 = 0; if (int.TryParse(s, out num) && num > 0 && int.TryParse(s2, out num2) && num2 > 0) { MemberInfo user = Users.GetUser(HiContext.Current.UserId); if (user == null) { this.context.Response.Write("请登录"); } else if (num2 > user.Points) { this.context.Response.Write("您的积分不足"); } else { switch (CouponHelper.AddCouponItemInfo(user, num)) { case CouponActionStatus.Success: this.context.Response.Write("兑换成功"); break; case CouponActionStatus.NotExists: this.context.Response.Write("优惠券不存在"); break; case CouponActionStatus.InconsistentInformationUser: this.context.Response.Write("用户信息不符"); break; case CouponActionStatus.InadequateInventory: this.context.Response.Write("该优惠券已被兑完"); break; case CouponActionStatus.CannotReceive: { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(num); this.context.Response.Write("你好,该优惠券每人只能兑换" + eFCoupon.UserLimitCount + "张"); break; } case CouponActionStatus.PointNotEnough: this.context.Response.Write("您的积分不足"); break; case CouponActionStatus.UnknowError: this.context.Response.Write("未知错误"); break; case CouponActionStatus.Overdue: this.context.Response.Write("优惠券已过期"); break; } } } }
public void UserGetCoupon() { string s = this.context.Request["couponId"]; string s2 = "领取失败"; MemberInfo user = Users.GetUser(HiContext.Current.UserId); if (user == null) { s2 = "请登录"; } else { int num = 0; if (!int.TryParse(s, out num) || num <= 0) { s2 = "请选择要领取的优惠券"; } switch (CouponHelper.UserGetCoupon(user, num)) { case CouponActionStatus.Success: s2 = "领取成功"; break; case CouponActionStatus.NotExists: s2 = "优惠券不存在"; break; case CouponActionStatus.InconsistentInformationUser: s2 = "用户信息不符"; break; case CouponActionStatus.InadequateInventory: s2 = "该优惠券已被领完"; break; case CouponActionStatus.CannotReceive: { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(num); s2 = "每人限领" + eFCoupon.UserLimitCount + "张"; break; } case CouponActionStatus.UnknowError: s2 = "未知错误"; break; case CouponActionStatus.CanNotGet: s2 = "该优惠券不能被领取"; break; case CouponActionStatus.Overdue: s2 = "优惠券已过期"; break; } } this.context.Response.Write(s2); }
private void SendPointCoupons(HttpContext context) { if (HiContext.Current.UserId == 0) { context.Response.Write("{\"Status\":\"0\"}"); } else { int num = context.Request["CouponId"].ToInt(0); int num2 = context.Request["NeedPoints"].ToInt(0); if (num > 0) { lock (RegionHandler.PointCouponslock) { switch (CouponHelper.AddCouponItemInfo(HiContext.Current.User, num)) { case CouponActionStatus.Success: context.Response.Write("{\"Status\":\"1\"}"); break; case CouponActionStatus.PointNotEnough: context.Response.Write("{\"Status\":\"-1\", \"Error\":\"您的积分不足\"}"); break; case CouponActionStatus.NotExists: context.Response.Write("{\"Status\":\"-1\", \"Error\":\"该优惠券已下线\"}"); break; case CouponActionStatus.Overdue: context.Response.Write("{\"Status\":\"-1\", \"Error\":\"该优惠券已过期\"}"); break; case CouponActionStatus.InadequateInventory: context.Response.Write("{\"Status\":\"-1\", \"Error\":\"该优惠券被领取完了\"}"); break; case CouponActionStatus.CannotReceive: { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(num); context.Response.Write("{\"Status\":\"-1\", \"Error\":\"你好,该优惠券每人只能兑换" + eFCoupon.UserLimitCount + "张\"}"); break; } default: context.Response.Write("{\"Status\":\"-1\", \"Error\":\"未知错误\"}"); break; } } } else { context.Response.Write("{\"Status\":\"-1\", \"Error\":\"未知错误\"}"); } } context.Response.End(); }
private void btnOK_Click(object sender, EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); masterSettings.IsOpenGiftCoupons = this.ooOpen.SelectedValue; if (this.ooOpen.SelectedValue) { masterSettings.GiftCouponList = this.hidSelectCouponIds.Value; int num = 0; string[] array = masterSettings.GiftCouponList.Split(','); foreach (string text in array) { if (!string.IsNullOrEmpty(text)) { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(text.ToInt(0)); if (eFCoupon == null) { this.ShowMsg("保存失败!部分优惠券已过期或剩余数量不足,请删除后重新选择。", false); this.Refresh(); return; } int couponSurplus = CouponHelper.GetCouponSurplus(text.ToInt(0)); if (eFCoupon.ClosingTime < DateTime.Now || couponSurplus <= 0) { this.ShowMsg("保存失败!部分优惠券已过期或剩余数量不足,请删除后重新选择。", false); this.Refresh(); return; } num++; } } if (num > 10) { this.ShowMsg("只可以选择10张优惠券,请删除部分优惠券。", false); this.Refresh(); return; } } else { masterSettings.GiftCouponList = ""; } SettingsManager.Save(masterSettings); this.BindCouponList(); this.ShowMsg("保存成功", true, ""); }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["couponId"], out this.couponId)) { this.hidCanShow.Value = "1"; } else { this.litCouponName = (Literal)this.FindControl("litCouponName"); this.litPrice = (Literal)this.FindControl("litPrice"); this.litCanUseProducts = (Literal)this.FindControl("litCanUseProducts"); this.litOrderUseLimit = (Literal)this.FindControl("litOrderUseLimit"); this.litStartTime = (Literal)this.FindControl("litStartTime"); this.litClosingTime = (Literal)this.FindControl("litClosingTime"); this.hidCouponId = (HtmlInputHidden)this.FindControl("hidCouponId"); this.hidCanUseProducts = (HtmlInputHidden)this.FindControl("hidCanUseProducts"); this.hidCanShow = (HtmlInputHidden)this.FindControl("hidCanShow"); CouponInfo eFCoupon = CouponHelper.GetEFCoupon(this.couponId); if (eFCoupon != null) { this.litCouponName.Text = eFCoupon.CouponName; this.litPrice.Text = eFCoupon.Price.F2ToString("f2"); this.litCanUseProducts.Text = (string.IsNullOrEmpty(eFCoupon.CanUseProducts) ? "全场商品可用" : "部分商品可用"); Literal literal = this.litOrderUseLimit; decimal?orderUseLimit = eFCoupon.OrderUseLimit; literal.Text = ((orderUseLimit.GetValueOrDefault() > default(decimal) && orderUseLimit.HasValue) ? ("订单满" + $"{eFCoupon.OrderUseLimit:F2}" + "元可用") : "无限制"); Literal literal2 = this.litStartTime; DateTime dateTime = eFCoupon.StartTime; literal2.Text = dateTime.ToString("yyyy.MM.dd"); Literal literal3 = this.litClosingTime; dateTime = eFCoupon.ClosingTime; literal3.Text = dateTime.ToString("yyyy.MM.dd"); this.hidCouponId.Value = this.couponId.ToString(); this.hidCanUseProducts.Value = eFCoupon.CanUseProducts; } else { this.hidCanShow.Value = "1"; } } }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(this.Page.Request.QueryString["couponId"], out this.couponId)) { base.GotoResourceNotFound(); } else if (!this.Page.IsPostBack) { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(this.couponId); if (eFCoupon != null) { this.lblCouponName.Text = eFCoupon.CouponName; this.lblPrice.Text = eFCoupon.Price.F2ToString("f2"); Label label = this.lblSendCount; int num = eFCoupon.SendCount; label.Text = num.ToString(); Label label2 = this.lblUserLimitCount; object text; if (eFCoupon.UserLimitCount != 0) { num = eFCoupon.UserLimitCount; text = num.ToString(); } else { text = "不限"; } label2.Text = (string)text; Label label3 = this.lblFullPrice; decimal?orderUseLimit = eFCoupon.OrderUseLimit; label3.Text = ((orderUseLimit.GetValueOrDefault() > default(decimal) && orderUseLimit.HasValue) ? ("满" + $"{eFCoupon.OrderUseLimit:F2}" + "元使用") : "无限制"); Label label4 = this.lblCalendarEndDate; DateTime dateTime = eFCoupon.ClosingTime; label4.Text = dateTime.ToString("yyyy-MM-dd"); Label label5 = this.lblCalendarStartDate; dateTime = eFCoupon.StartTime; label5.Text = dateTime.ToString("yyyy-MM-dd"); if (!string.IsNullOrEmpty(eFCoupon.CanUseProducts)) { this.radSomeProducts.Checked = true; DataTable productBaseInfo = ProductHelper.GetProductBaseInfo(eFCoupon.CanUseProducts); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < productBaseInfo.Rows.Count; i++) { string text2 = productBaseInfo.Rows[i]["ProductId"].ToString(); string text3 = productBaseInfo.Rows[i]["ProductName"].ToString(); if (stringBuilder.Length > 0) { stringBuilder.Append(",,," + text2 + "|||" + text3); } else { stringBuilder.Append(text2 + "|||" + text3); } } this.hidSelectProducts.Value = stringBuilder.ToString(); } else { this.radAll.Checked = true; } if (eFCoupon.ObtainWay == 0) { this.radActiveReceive.Checked = true; } else if (eFCoupon.ObtainWay == 1) { this.radGrant.Checked = true; } else if (eFCoupon.ObtainWay == 2) { this.radExchange.Checked = true; Label label6 = this.lblNeedPoint; num = eFCoupon.NeedPoint; label6.Text = num.ToString(); } if (eFCoupon.UseWithPanicBuying) { this.chkPanicBuying.Checked = true; } if (eFCoupon.UseWithGroup) { this.chkGroup.Checked = true; } } else { base.GotoResourceNotFound(); } } }
private void btnSure_Click(object sender, EventArgs e) { string text = base.Request.Form["CheckBoxGroup"].ToNullString(); string text2 = this.Page.Request["UserIds"].ToNullString(); if (string.IsNullOrEmpty(text)) { this.ShowMsg("请选择赠送的优惠券", false); } else { List <CouponInfo> list = new List <CouponInfo>(); string[] array = text.Split(','); foreach (string text3 in array) { if (!string.IsNullOrEmpty(text3)) { int num = 0; if (int.TryParse(text3, out num) && num > 0) { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(num); if (eFCoupon != null) { list.Add(eFCoupon); } } } } if (list.Count == 0) { this.btnSure.Text = "确 定"; this.btnSure.Enabled = true; this.ShowMsg("请选择赠送的优惠券", false); } else { string empty = string.Empty; int num2 = 0; int num3 = 0; int num4 = 0; string[] array2 = text2.Split(','); foreach (string s in array2) { int num5 = 0; if (int.TryParse(s, out num5) && num5 > 0) { MemberInfo user = Users.GetUser(num5); num4 = 0; decimal num6 = default(decimal); foreach (CouponInfo item in list) { CouponItemInfo couponItemInfo = new CouponItemInfo(); couponItemInfo.UserId = user.UserId; couponItemInfo.UserName = user.UserName; couponItemInfo.CanUseProducts = item.CanUseProducts; couponItemInfo.ClosingTime = item.ClosingTime; couponItemInfo.CouponId = item.CouponId; couponItemInfo.CouponName = item.CouponName; couponItemInfo.OrderUseLimit = item.OrderUseLimit; couponItemInfo.Price = item.Price; couponItemInfo.StartTime = item.StartTime; couponItemInfo.UseWithGroup = item.UseWithGroup; couponItemInfo.UseWithPanicBuying = item.UseWithPanicBuying; couponItemInfo.UseWithFireGroup = item.UseWithFireGroup; couponItemInfo.GetDate = DateTime.Now; CouponActionStatus couponActionStatus = CouponHelper.AddCouponItemInfo(couponItemInfo); num6 += item.Price; if (couponActionStatus == CouponActionStatus.Success) { num2++; num4++; } else { num3++; } } if (num4 > 0) { Messenger.GiftCoupons(user, num4, num6); } } } if (num2 + num3 > 0) { base.CloseWindow("成功发送" + num2 + "张优惠券," + num3 + "张优惠券发送失败"); } else { this.ShowMsg("成功失败", false); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(this.Page.Request.QueryString["couponId"], out this.couponId)) { base.GotoResourceNotFound(); } else { this.btnEditCoupons.Click += this.btnEditCoupons_Click; Dictionary <string, object> calendarParameter = this.calendarStartDate.CalendarParameter; DateTime now = DateTime.Now; calendarParameter.Add("startDate ", now.ToString("yyyy-MM-dd")); Dictionary <string, object> calendarParameter2 = this.calendarEndDate.CalendarParameter; now = DateTime.Now; calendarParameter2.Add("startDate ", now.ToString("yyyy-MM-dd")); if (!this.Page.IsPostBack) { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(this.couponId); if (eFCoupon != null) { this.txtCouponName.Text = eFCoupon.CouponName; this.txtPrice.Text = eFCoupon.Price.F2ToString("f2"); TextBox textBox = this.txtSendCount; int num = eFCoupon.SendCount; textBox.Text = num.ToString(); HtmlSelect htmlSelect = this.ddlUserLimitCount; num = eFCoupon.UserLimitCount; htmlSelect.Value = num.ToString(); decimal?orderUseLimit = eFCoupon.OrderUseLimit; if (orderUseLimit.GetValueOrDefault() > default(decimal) && orderUseLimit.HasValue) { this.radUseFullCut.Checked = true; this.txtFullPrice.Text = $"{eFCoupon.OrderUseLimit:F2}"; } else { this.radNoLimit.Checked = true; this.txtFullPrice.Text = ""; } this.calendarEndDate.SelectedDate = eFCoupon.ClosingTime; this.calendarStartDate.SelectedDate = eFCoupon.StartTime; if (!string.IsNullOrEmpty(eFCoupon.CanUseProducts)) { this.radSomeProducts.Checked = true; DataTable productBaseInfo = ProductHelper.GetProductBaseInfo(eFCoupon.CanUseProducts); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < productBaseInfo.Rows.Count; i++) { string str = productBaseInfo.Rows[i]["ProductId"].ToString(); string str2 = productBaseInfo.Rows[i]["ProductName"].ToString(); if (stringBuilder.Length > 0) { stringBuilder.Insert(0, str + "|||" + str2 + ",,,"); } else { stringBuilder.Append(str + "|||" + str2); } } this.hidSelectProducts.Value = stringBuilder.ToString(); } else { this.radAll.Checked = true; } if (eFCoupon.ObtainWay == 0) { this.radActiveReceive.Checked = true; } else if (eFCoupon.ObtainWay == 1) { this.radGrant.Checked = true; } else if (eFCoupon.ObtainWay == 2) { this.radExchange.Checked = true; TextBox textBox2 = this.txtNeedPoint; num = eFCoupon.NeedPoint; textBox2.Text = num.ToString(); } if (eFCoupon.UseWithPanicBuying) { this.chkPanicBuying.Checked = true; } if (eFCoupon.UseWithGroup) { this.chkGroup.Checked = true; } if (eFCoupon.UseWithFireGroup) { this.chkFireGroup.Checked = true; } Label label = this.lblLastCount; num = CouponHelper.GetCouponObtainNum(this.couponId, 0); label.Text = num.ToString(); } else { base.GotoResourceNotFound(); } } } }