Exemplo n.º 1
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(CouponsSearch query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                DbQueryResult couponInfos = CouponHelper.GetCouponInfos(query, "");
                dataGridViewModel.rows  = DataHelper.DataTableToDictionary(couponInfos.Data);
                dataGridViewModel.total = couponInfos.TotalRecords;
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    CouponInfo couponInfo    = row.ToObject <CouponInfo>();
                    int        couponSurplus = CouponHelper.GetCouponSurplus(couponInfo.CouponId);
                    row.Add("LastCount", couponSurplus);
                    int couponObtainUserNum = CouponHelper.GetCouponObtainUserNum(couponInfo.CouponId);
                    int couponObtainNum     = CouponHelper.GetCouponObtainNum(couponInfo.CouponId, 0);
                    row.Add("UserCount", couponObtainUserNum);
                    row.Add("UserGetCount", couponObtainNum);
                    int couponUsedNum = CouponHelper.GetCouponUsedNum(couponInfo.CouponId);
                    row.Add("UseCount", couponUsedNum);
                    row.Add("IsCouponEnd", this.IsCouponEnd(couponInfo.ClosingTime));
                }
            }
            return(dataGridViewModel);
        }
Exemplo n.º 2
0
 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();
             }
         }
     }
 }
Exemplo n.º 3
0
        private void SendCoupons(HttpContext context)
        {
            if (HiContext.Current.UserId == 0)
            {
                context.Response.Write("{\"Status\":\"0\"}");
            }
            else
            {
                int num = context.Request["CouponId"].ToInt(0);
                if (num > 0)
                {
                    lock (RegionHandler.Couponslock)
                    {
                        switch (CouponHelper.AddCouponItemInfo(HiContext.Current.User, num))
                        {
                        case CouponActionStatus.Success:
                        {
                            CouponInfo eFCoupon2       = CouponHelper.GetEFCoupon(num);
                            int        couponObtainNum = CouponHelper.GetCouponObtainNum(num, HiContext.Current.UserId);
                            if (couponObtainNum < eFCoupon2.UserLimitCount || eFCoupon2.UserLimitCount == 0)
                            {
                                context.Response.Write("{\"Status\":\"2\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"Status\":\"1\"}");
                            }
                            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();
        }