Example #1
0
        private void CouponComment()
        {
            int     cid    = GetInt("couponid");
            int     uid    = GetInt("uid");
            string  msg    = GetString("message");
            var     coupon = CouponHelper.GetItem(cid);
            Comment c      = new Comment();

            c.SellerId = coupon.SellerId;
            c.TypeId   = coupon.Id;
            c.UserId   = uid;
            c.Content  = msg;
            c.Type     = CommentType.Coupons;
            //冗余两个字段
            c.Img   = coupon.ImgUrl;
            c.Title = coupon.Title;

            try
            {
                CommentHelper.Create(c);
                coupon.Commentnum += 1;
                CouponHelper.Update(coupon);
            }
            catch
            {
                ReturnErrorMsg("fail");
                throw;
            }
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
Example #2
0
 private void CreateCoupons()
 {
     _couponService.AddCoupon(CouponHelper.GetCoupon(CouponTypeEnum.AmountCoupon5For50));
     _couponService.AddCoupon(CouponHelper.GetCoupon(CouponTypeEnum.AmountCoupon50For300));
     _couponService.AddCoupon(CouponHelper.GetCoupon(CouponTypeEnum.RateCoupon10For150));
     _couponService.GetCoupons().Print();
 }
Example #3
0
 protected override void AttachChildControls()
 {
     this.rptCouponsAct            = (VshopTemplatedRepeater)this.FindControl("rptCouponsAct");
     this.rptCouponsAct.DataSource = CouponHelper.GetCouponsActNow();
     this.rptCouponsAct.DataBind();
     PageTitle.AddSiteNameTitle("优惠卷活动");
 }
        private void GetCouponInfo(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            StringBuilder builder = new StringBuilder("{");
            int           result  = 0;

            if (!int.TryParse(context.Request["id"], out result))
            {
                builder.Append("\"Status\":\"0\"}");
                context.Response.Write(builder.ToString());
            }
            CouponInfo coupon = CouponHelper.GetCoupon(result);

            if (coupon == null)
            {
                builder.Append("\"Status\":\"1\"}");
                context.Response.Write(builder.ToString());
            }
            else
            {
                var type = new {
                    Status    = 2,
                    Count     = coupon.StockNum - coupon.ReceiveNum,
                    BeginTime = coupon.BeginDate,
                    EndTime   = coupon.EndDate
                };
                IsoDateTimeConverter converter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                };
                context.Response.Write(JsonConvert.SerializeObject(type, Formatting.Indented, new JsonConverter[] { converter }));
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.btnAddArticle.Click += new EventHandler(this.btnAddArticle_Click);
            if (!this.Page.IsPostBack)
            {
                this.dropArticleCategory.DataBind();
                if (!string.IsNullOrEmpty(this.Page.Request.QueryString["categoryId"]))
                {
                    int result = 0;
                    int.TryParse(this.Page.Request.QueryString["categoryId"], out result);
                    this.dropArticleCategory.SelectedValue = new int?(result);
                }


                DataTable couponList = new DataTable();
                couponList = CouponHelper.GetAllCoupons();
                DDLCoupon.Items.Add("未选择");
                foreach (DataRow row in couponList.Rows)
                {
                    ListItem item = new ListItem();
                    item.Text  = row["name"].ToString();
                    item.Value = row["CouponId"].ToString();
                    DDLCoupon.Items.Add(item);
                }
            }
        }
Example #6
0
        public string GetPrizeType(PrizeTypes PrizeType, int PrizeValue)
        {
            string result = string.Empty;

            switch (PrizeType)
            {
            case PrizeTypes.Integral:
                result = PrizeValue + "积分; ";
                break;

            case PrizeTypes.Coupou:
            {
                CouponInfo coupon = CouponHelper.GetCoupon(PrizeValue);
                result = ((coupon == null) ? " " : ((!(coupon.ClosingTime > coupon.StartTime)) ? (coupon.Price + "元优惠券<font style='color:red;'>(已失效)</font>; ") : (coupon.Price + "元优惠券; ")));
                break;
            }

            case PrizeTypes.Gift:
            {
                GiftInfo giftDetails = GiftHelper.GetGiftDetails(PrizeValue);
                result = ((giftDetails == null) ? " " : (giftDetails.Name + "; "));
                break;
            }
            }
            return(result);
        }
Example #7
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     try
     {
         string[] allKeys = context.Request.Params.AllKeys;
         DateTime now     = DateTime.Now;
         if (allKeys.Contains <string>("time"))
         {
             now = DateTime.Parse(context.Request["time"].ToString());
         }
         DataTable unFinishedCoupon = CouponHelper.GetUnFinishedCoupon(now, (CouponType)3);
         var       type             = new
         {
             type = "success",
             data = unFinishedCoupon
         };
         string s = JsonConvert.SerializeObject(type);
         context.Response.Write(s);
     }
     catch (Exception exception)
     {
         context.Response.Write("{\"type\":\"error\",\"data\":\"" + exception.Message + "\"}");
     }
 }
Example #8
0
 protected override void AttachChildControls()
 {
     this.pointList    = (Common_Point_PointList)this.FindControl("Common_Point_PointList");
     this.pager        = (Pager)this.FindControl("pager");
     this.litUserPoint = (Literal)this.FindControl("litUserPoint");
     this.litMyCoupons = (Literal)this.FindControl("litMyCoupons");
     PageTitle.AddSiteNameTitle("我的积分");
     this.pointList.ItemDataBound += this.pointList_ItemDataBound;
     if (!this.Page.IsPostBack)
     {
         this.BindPoint();
         CouponItemInfo couponItemInfo = new CouponItemInfo();
         couponItemInfo.CouponStatus = 0;
         MemberInfo user = HiContext.Current.User;
         if (user.UserId != 0)
         {
             Literal literal = this.litUserPoint;
             int     num     = user.Points;
             literal.Text = num.ToString();
             Literal literal2 = this.litMyCoupons;
             num           = CouponHelper.GetUserObtainCouponNum(HiContext.Current.UserId);
             literal2.Text = num.ToString();
         }
     }
 }
 protected override void Render(HtmlTextWriter writer)
 {
     if (HiContext.Current.SiteSettings.IsOpenAppPromoteCoupons)
     {
         decimal couponsAmount = CouponHelper.GetCouponsAmount(HiContext.Current.SiteSettings.AppPromoteCouponList);
         if (couponsAmount > decimal.Zero)
         {
             string text    = "/Storage/master/QRCode/" + HttpContext.Current.Request.Url.Host + "_appdownload.png";
             string siteUrl = SettingsManager.GetMasterSettings().SiteUrl;
             string str     = (siteUrl.Contains("http://") || siteUrl.Contains("https://")) ? siteUrl : ("http://" + siteUrl);
             str += (siteUrl.EndsWith("/") ? "" : "/WapShop/AppDownload");
             Globals.CreateQRCode(str, text, false, ImageFormats.Png);
             base.Text = string.Format("<img src=\"{0}\" CouponsAmount=\"{1}\" {2}/>", text, couponsAmount, (this.Width > 0) ? ("width=\"" + this.Width + "px\"") : "");
             if (this.ShowText)
             {
                 base.Text += string.Format("<p>首次下载APP<br>即可享<span>{0}</span>元红包</p>", couponsAmount.F2ToString("f2"));
             }
             base.Render(writer);
         }
         else
         {
             base.Text = "";
         }
     }
     else
     {
         base.Text = "";
     }
 }
Example #10
0
        protected void BindCouponList()
        {
            //if (string.IsNullOrEmpty(this.couponName)&&
            //    string.IsNullOrEmpty(this.couponOrder)&&
            //    !this.couponstatus.HasValue&&
            //    !this.CouponId.HasValue)
            //{
            //    return;
            //}
            DbQueryResult couponsList = CouponHelper.GetCouponsList(new CouponItemInfoQuery
            {
                CounponName  = this.couponName,
                OrderId      = this.couponOrder,
                CouponId     = this.CouponId,
                UserName     = this.userName,
                AddUserName  = this.addUserName,
                BeginTime    = !this.dateStart.HasValue ? "" : this.dateStart.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                EndTime      = !this.dateEnd.HasValue ? "" : (this.dateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59"),
                CouponStatus = this.couponstatus,
                PageIndex    = this.pager.PageIndex,
                PageSize     = this.pager.PageSize,
                SortBy       = "GenerateTime",
                SortOrder    = SortAction.Desc
            });

            this.pager.TotalRecords    = couponsList.TotalRecords;
            this.grdCoupons.DataSource = couponsList.Data;
            this.grdCoupons.DataBind();
        }
Example #11
0
        private void ExportExcelUserCoupons()
        {
            DbQueryResult couponsList = CouponHelper.GetCouponsListToExport(new CouponItemInfoQuery
            {
                CounponName  = this.couponName,
                OrderId      = this.couponOrder,
                CouponId     = this.CouponId,
                UserName     = this.userName,
                AddUserName  = this.addUserName,
                BeginTime    = !this.dateStart.HasValue ? "" : this.dateStart.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                EndTime      = !this.dateEnd.HasValue ? "" : (this.dateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59"),
                CouponStatus = this.couponstatus
            });
            DataTable dtResult = (DataTable)couponsList.Data;

            if (dtResult == null || dtResult.Rows.Count == 0)
            {
                this.ShowMsg("没有数据需要导出!", false);
                return;
            }
            DataTable dtcoupons = new DataTable();

            dtcoupons.Columns.Add("用户名", typeof(string));
            dtcoupons.Columns.Add("劵名称", typeof(string));
            dtcoupons.Columns.Add("发放时间", typeof(string));
            dtcoupons.Columns.Add("使用时间", typeof(string));
            dtcoupons.Columns.Add("使用金额", typeof(string));
            dtcoupons.Columns.Add("订单号", typeof(string));
            for (var i = 0; i < dtResult.Rows.Count; i++)
            {
                DataRow dr = dtcoupons.NewRow();
                dr["用户名"]  = dtResult.Rows[i]["UserName"].ToString();
                dr["劵名称"]  = dtResult.Rows[i]["Name"].ToString();
                dr["发放时间"] = dtResult.Rows[i]["GenerateTime"].ToString();
                dr["使用时间"] = dtResult.Rows[i]["UsedTime"].ToString();
                dr["使用金额"] = dtResult.Rows[i]["DiscountValue"].ToString();
                dr["订单号"]  = dtResult.Rows[i]["Orderid"].ToString();
                dtcoupons.Rows.Add(dr);
            }
            MemoryStream ms = NPOIExcelHelper.ExportToExcel(dtcoupons, "优惠券使用明细");

            this.Page.Response.Clear();
            this.Page.Response.Buffer  = false;
            this.Page.Response.Charset = "GB2312";
            if (!(this.calendarStart.SelectedDate.HasValue && this.calendarEnd.SelectedDate.HasValue))
            {
                this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=优惠券使用明细.xlsx");
            }
            else
            {
                this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=优惠券使用明细_" + this.dateStart.Value.ToString("yyyyMMdd") + "-" + this.dateEnd.Value.ToString("yyyyMMdd") + ".xlsx");
            }
            this.Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            this.Page.Response.ContentType     = "application/octet-stream";
            this.Page.EnableViewState          = false;
            this.Page.Response.BinaryWrite(ms.ToArray());
            ms.Dispose();
            ms.Close();
            this.Page.Response.End();
        }
Example #12
0
        public static GamePrizeInfo UserPrize(int gameId, int useId)
        {
            IList <GamePrizeInfo> gamePrizeListsByGameId = GetGamePrizeListsByGameId(gameId);
            int           num  = gamePrizeListsByGameId.Max <GamePrizeInfo>((Func <GamePrizeInfo, int>)(p => p.PrizeRate));
            GamePrizeInfo item = new GamePrizeInfo {
                PrizeId    = 0,
                PrizeRate  = (num >= 100) ? 0 : 100,
                PrizeGrade = PrizeGrade.未中奖
            };

            gamePrizeListsByGameId.Add(item);
            GamePrizeInfo info2 = ChouJiang(gamePrizeListsByGameId);

            if ((info2.PrizeId != 0) && (info2.PrizeCount <= 0))
            {
                info2 = item;
            }
            if (((info2.PrizeId != 0) && (info2.PrizeType == PrizeType.赠送优惠券)) && (CouponHelper.IsCanSendCouponToMember(int.Parse(info2.GiveCouponId), useId) != SendCouponResult.正常领取))
            {
                info2 = item;
            }
            PrizeResultInfo model = new PrizeResultInfo {
                GameId  = gameId,
                PrizeId = info2.PrizeId,
                UserId  = useId
            };

            new PrizeResultDao().AddPrizeLog(model);
            return(info2);
        }
Example #13
0
        public static string GetPrizeFullName(PrizeResultViewInfo item)
        {
            switch (item.PrizeType)
            {
            case PrizeType.赠送积分:
                return(string.Format("{0} 积分", item.GivePoint));

            case PrizeType.赠送优惠券:
            {
                CouponInfo coupon = CouponHelper.GetCoupon(int.Parse(item.GiveCouponId));
                if (coupon == null)
                {
                    return("优惠券" + item.GiveCouponId + "[已删除]");
                }
                return(coupon.CouponName);
            }

            case PrizeType.赠送商品:
            {
                ProductInfo productBaseInfo = ProductHelper.GetProductBaseInfo(int.Parse(item.GiveShopBookId));
                if (productBaseInfo == null)
                {
                    return("赠送商品[已删除]");
                }
                return(productBaseInfo.ProductName);
            }
            }
            return("");
        }
Example #14
0
 protected void DelBtn_Click(object sender, System.EventArgs e)
 {
     System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>();
     foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdCoupondsList.Rows)
     {
         if (gridViewRow.RowIndex >= 0)
         {
             System.Web.UI.WebControls.CheckBox checkBox = gridViewRow.Cells[0].FindControl("cbId") as System.Web.UI.WebControls.CheckBox;
             if (checkBox.Checked)
             {
                 list.Add(int.Parse(this.grdCoupondsList.DataKeys[gridViewRow.RowIndex].Value.ToString()));
             }
         }
     }
     if (list.Count <= 0)
     {
         this.ShowMsg("请至少选择一条要删除的数据!", false);
         return;
     }
     foreach (int current in list)
     {
         int num = 0;
         if (!this.bInt(current.ToString(), ref num))
         {
             this.ShowMsg("选择优惠券出错!", false);
             return;
         }
     }
     foreach (int current2 in list)
     {
         CouponHelper.DeleteCoupon(current2);
     }
     this.ShowMsg("删除优惠券成功!", true);
     this.BindData();
 }
        public void CopyRedEnvelope(string openId, MemberInfo memberInfo)
        {
            IList <RedEnvelopeGetRecordInfo> list = WeiXinRedEnvelopeProcessor.GettWaitToUserRedEnvelopeGetRecord(openId);

            foreach (RedEnvelopeGetRecordInfo item in list)
            {
                WeiXinRedEnvelopeInfo weiXinRedEnvelope = WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(item.RedEnvelopeId);
                if (weiXinRedEnvelope != null)
                {
                    CouponItemInfo couponItemInfo = new CouponItemInfo();
                    couponItemInfo.UserId             = memberInfo.UserId;
                    couponItemInfo.UserName           = memberInfo.UserName;
                    couponItemInfo.CanUseProducts     = "";
                    couponItemInfo.ClosingTime        = weiXinRedEnvelope.EffectivePeriodEndTime;
                    couponItemInfo.CouponId           = 0;
                    couponItemInfo.RedEnvelopeId      = weiXinRedEnvelope.Id;
                    couponItemInfo.CouponName         = weiXinRedEnvelope.Name;
                    couponItemInfo.OrderUseLimit      = weiXinRedEnvelope.EnableUseMinAmount;
                    couponItemInfo.Price              = item.Amount;
                    couponItemInfo.StartTime          = weiXinRedEnvelope.EffectivePeriodStartTime;
                    couponItemInfo.UseWithGroup       = false;
                    couponItemInfo.UseWithPanicBuying = false;
                    couponItemInfo.GetDate            = DateTime.Now;
                    if (WeiXinRedEnvelopeProcessor.SetRedEnvelopeGetRecordToMember(item.Id, memberInfo.UserName))
                    {
                        CouponActionStatus couponActionStatus = CouponHelper.AddRedEnvelopeItemInfo(couponItemInfo);
                    }
                }
            }
        }
Example #16
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     try
     {
         if (Globals.GetCurrentManagerUserId() <= 0)
         {
             context.Response.Write("{\"type\":\"error\",\"data\":\"请先登录\"}");
             context.Response.End();
         }
         CouponInfo coupon = CouponHelper.GetCoupon(int.Parse(context.Request["id"].ToString()));
         var        type   = new
         {
             type = "success",
             time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
             data = coupon
         };
         IsoDateTimeConverter converter = new IsoDateTimeConverter
         {
             DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
         };
         string s = JsonConvert.SerializeObject(type, Formatting.Indented, new JsonConverter[] { converter });
         context.Response.Write(s);
     }
     catch (Exception exception)
     {
         context.Response.Write("{\"type\":\"error\",\"data\":\"" + exception.Message + "\"}");
     }
 }
        protected override void AttachChildControls()
        {
            this.hidHasCoupon = (HtmlInputHidden)this.FindControl("hidHasCoupon");
            int useType = 1;

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["usedType"]))
            {
                int.TryParse(this.Page.Request.QueryString["usedType"], out useType);
            }
            if (HiContext.Current.User != null)
            {
                DataTable userCoupons = CouponHelper.GetUserCoupons(HiContext.Current.UserId, useType);
                if (userCoupons != null)
                {
                    this.rptCoupons            = (Repeater)this.FindControl("rptCoupons");
                    this.rptCoupons.DataSource = userCoupons;
                    this.rptCoupons.DataBind();
                }
                if (userCoupons == null || userCoupons.Rows.Count <= 0)
                {
                    this.hidHasCoupon.Value = "0";
                }
                PageTitle.AddSiteNameTitle("我的优惠券");
            }
        }
Example #18
0
        private void btnEditCoupons_Click(object sender, EventArgs e)
        {
            decimal num;
            decimal?nullable;
            int     num2;

            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else if (!this.calendarEndDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择结束日期!", false);
                }
                else if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                {
                    this.ShowMsg("开始日期不能晚于结束日期!", false);
                }
                else
                {
                    string     msg    = string.Empty;
                    CouponInfo target = new CouponInfo {
                        CouponId      = this.couponId,
                        Name          = this.txtCouponName.Text,
                        ClosingTime   = this.calendarEndDate.SelectedDate.Value,
                        StartTime     = this.calendarStartDate.SelectedDate.Value,
                        Amount        = nullable,
                        DiscountValue = num,
                        NeedPoint     = num2
                    };
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <CouponInfo>(target, new string[] { "ValCoupon" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                            this.ShowMsg(msg, false);
                            return;
                        }
                    }
                    CouponActionStatus status = CouponHelper.UpdateCoupon(target);
                    if (status == CouponActionStatus.Success)
                    {
                        this.RestCoupon();
                        this.ShowMsg("成功修改了优惠券信息", true);
                    }
                    else if (status == CouponActionStatus.DuplicateName)
                    {
                        this.ShowMsg("修改优惠券信息错误,已经具有此优惠券名称", false);
                    }
                    else
                    {
                        this.ShowMsg("未知错误", false);
                        this.RestCoupon();
                    }
                }
            }
        }
Example #19
0
        protected override void AttachChildControls()
        {
            string url = this.Page.Request.QueryString["returnUrl"];

            if (!string.IsNullOrWhiteSpace(this.Page.Request.QueryString["returnUrl"]))
            {
                this.Page.Response.Redirect(url);
            }
            string str2 = this.Page.Request.QueryString["status"];

            if (string.IsNullOrEmpty(str2))
            {
                str2 = "1";
            }
            MemberInfo currentMember = MemberProcessor.GetCurrentMember();
            int        num           = 0;

            int.TryParse(str2, out num);
            this.rptUseableCouponList = (VshopTemplatedRepeater)this.FindControl("rptUseableCouponList");

            this.rptCouponsAct              = (VshopTemplatedRepeater)this.FindControl("rptCouponsAct");
            this.rptCouponsAct.ItemCommand += new RepeaterCommandEventHandler(this.rptCouponsAct_ItemCommand);
            this.rptCouponsAct.DataSource   = CouponHelper.GetCouponsActNow();
            this.rptCouponsAct.DataBind();

            DataTable dtData = VshopBrowser.GetLotteryActivity_Valid(0, currentMember.UserId);

            this.rptUseableCouponList.DataSource = dtData;
            this.rptUseableCouponList.DataBind();

            PageTitle.AddSiteNameTitle("微信红包活动");
        }
Example #20
0
        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;
                    }
                }
            }
        }
Example #21
0
        private void GetCouponInfo(System.Web.HttpContext context)
        {
            context.Response.ContentType = "application/json";
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("{");
            int couponId = 0;

            if (!int.TryParse(context.Request["id"], out couponId))
            {
                stringBuilder.Append("\"Status\":\"0\"}");
                context.Response.Write(stringBuilder.ToString());
            }
            CouponInfo coupon = CouponHelper.GetCoupon(couponId);

            if (coupon == null)
            {
                stringBuilder.Append("\"Status\":\"1\"}");
                context.Response.Write(stringBuilder.ToString());
                return;
            }
            var value = new
            {
                Status    = 2,
                Count     = coupon.StockNum - coupon.ReceiveNum,
                BeginTime = coupon.BeginDate,
                EndTime   = coupon.EndDate
            };
            IsoDateTimeConverter isoDateTimeConverter = new IsoDateTimeConverter();

            isoDateTimeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            context.Response.Write(JsonConvert.SerializeObject(value, Formatting.Indented, new JsonConverter[]
            {
                isoDateTimeConverter
            }));
        }
Example #22
0
        public int GetCouponSurplus(int CouponId)
        {
            HiddenField hiddenField = this.hidSelectCouponIds;

            hiddenField.Value = hiddenField.Value + CouponId + ",";
            return(CouponHelper.GetCouponSurplus(CouponId));
        }
        private void SendCouponToSearchUser(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int result = 0;

            if (!int.TryParse(context.Request["couponId"], out result))
            {
                context.Response.Write(JsonConvert.SerializeObject(new { status = "err", msg = "参数错误!" }));
            }
            else
            {
                try
                {
                    if (CouponHelper.SendCouponToMemebers(result))
                    {
                        context.Response.Write(JsonConvert.SerializeObject(new { status = "ok", msg = "发送成功!" }));
                    }
                    else
                    {
                        context.Response.Write(JsonConvert.SerializeObject(new { status = "err", msg = "发送失败!" }));
                    }
                }
                catch (Exception)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new { status = "err", msg = "发送出错!" }));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.radMatch.Items[0].Text   = "模糊匹配";
            this.radMatch.Items[1].Text   = "精确匹配";
            this.radDisable.Items[0].Text = "启用";
            this.radDisable.Items[1].Text = "禁用";
            this.chkNo.Enabled            = (ReplyHelper.GetMismatchReply() == null);
            this.chkSub.Enabled           = (ReplyHelper.GetSubscribeReply() == null);
            IList <CouponInfo> allUsedCoupons = CouponHelper.GetAllUsedCoupons(1);

            if (allUsedCoupons != null && allUsedCoupons.Count > 0)
            {
                foreach (CouponInfo item in allUsedCoupons)
                {
                    if (CouponHelper.GetCouponSurplus(item.CouponId) > 0)
                    {
                        this.ddlCoupon.Items.Add(new ListItem(item.CouponName.ToNullString(), item.CouponId.ToNullString()));
                    }
                }
            }
            if (this.ddlCoupon.Items.Count == 0)
            {
                this.ddlsubType.Items.RemoveAt(1);
                this.ddlCoupon.Items.Add(new ListItem("请选择优惠券", "0"));
            }
            if (!this.chkNo.Enabled)
            {
                this.chkNo.ToolTip = "该类型已被使用";
            }
            if (!this.chkSub.Enabled)
            {
                this.chkSub.ToolTip = "该类型已被使用";
            }
        }
Example #25
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.btnAddCoupons.Click += new System.EventHandler(this.btnAddCoupons_Click);
     if (CustomConfigHelper.Instance.IsSanzuo == true || CustomConfigHelper.Instance.BusinessName == "爽爽挝啡")
     {
         hidIsSanZuo.Value = "1";
         List <CategoryQuery> category = new List <CategoryQuery>();
         category = CouponHelper.GetHishop_Categories();
         DDLcategory.Items.Add("未选择");
         foreach (CategoryQuery ca in category)
         {
             ListItem item = new ListItem();
             item.Text  = ca.Name;
             item.Value = ca.CategoryId.ToString();
             DDLcategory.Items.Add(item);
         }
         List <CategoryQuery> clientuser = new List <CategoryQuery>();
         clientuser = CouponHelper.Getaspnet_ManagersClientUserId();
         DDLservice.Items.Add("未选择");
         foreach (CategoryQuery ct in clientuser)
         {
             ListItem item = new ListItem();
             item.Text  = ct.UserName;
             item.Value = ct.ClientUserId.ToString();
             DDLservice.Items.Add(item);
         }
     }
 }
Example #26
0
        private void SendSendCouponToUsers(int couponId)
        {
            MemberInfo user = HiContext.Current.User;

            if (HiContext.Current.User != null && !HiContext.Current.User.IsSubscribe)
            {
                this.litPrompt.Text  = "您尚未关注公众号!";
                this.buy.NavigateUrl = "Default.aspx";
                this.buy.Text        = "返回商城首页";
            }
            else
            {
                CouponActionStatus couponActionStatus = CouponHelper.AddCouponItemInfo(user, couponId);
                if (couponActionStatus == CouponActionStatus.Success)
                {
                    this.litPrompt.Text  = "优惠券领取成功!";
                    this.buy.NavigateUrl = "Default.aspx";
                }
                else
                {
                    this.litPrompt.Text = "优惠券领取失败!";
                    if (couponActionStatus == CouponActionStatus.InadequateInventory)
                    {
                        this.litPrompt.Text = "抱歉,优惠券已领完!";
                    }
                    if (couponActionStatus == CouponActionStatus.CannotReceive)
                    {
                        this.litPrompt.Text = "您已领过该优惠券!";
                    }
                    this.buy.NavigateUrl = "Default.aspx";
                    this.buy.Text        = "返回商城";
                }
            }
        }
Example #27
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["couponId"], out this.couponId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btnEditCoupons.Click += new System.EventHandler(this.btnEditCoupons_Click);
     if (!this.Page.IsPostBack)
     {
         CouponInfo coupon = CouponHelper.GetCoupon(this.couponId);
         if (coupon == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         if (coupon.ClosingTime.CompareTo(System.DateTime.Now) < 0)
         {
             this.ShowMsg("该优惠券已经结束!", false);
             return;
         }
         Globals.EntityCoding(coupon, false);
         this.lblEditCouponId.Text = coupon.CouponId.ToString();
         this.txtCouponName.Text   = coupon.Name;
         if (coupon.Amount.HasValue)
         {
             this.txtAmount.Text = string.Format("{0:F2}", coupon.Amount);
         }
         this.txtDiscountValue.Text          = coupon.DiscountValue.ToString("F2");
         this.calendarEndDate.SelectedDate   = new System.DateTime?(coupon.ClosingTime);
         this.calendarStartDate.SelectedDate = new System.DateTime?(coupon.StartTime);
         this.txtNeedPoint.Text = coupon.NeedPoint.ToString();
     }
 }
Example #28
0
 public void ProcessRequest(System.Web.HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     try
     {
         string[]        allKeys = context.Request.Params.AllKeys;
         System.DateTime end     = System.DateTime.Now;
         if (allKeys.Contains("time"))
         {
             end = System.DateTime.Parse(context.Request["time"].ToString());
         }
         System.Data.DataTable unFinishedCoupon = CouponHelper.GetUnFinishedCoupon(end, new CouponType?(CouponType.活动赠送));
         var value = new
         {
             type = "success",
             data = unFinishedCoupon
         };
         string s = JsonConvert.SerializeObject(value);
         context.Response.Write(s);
     }
     catch (System.Exception ex)
     {
         context.Response.Write("{\"type\":\"error\",\"data\":\"" + ex.Message + "\"}");
     }
 }
Example #29
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int      i     = 0;
            int      num2  = 0;
            int      num3  = 1;
            DateTime now   = DateTime.Now;
            DateTime time2 = DateTime.Now;

            if (!this.bInt(this.txt_id.Text, ref i))
            {
                this.ShowMsg("没有找到这张优惠券的信息!", false);
            }
            if (!this.bInt(this.txt_totalNum.Text, ref num2))
            {
                this.ShowMsg("请输入正确的发放总量!", false);
            }
            if (!this.bInt(this.ddl_maxNum.SelectedValue, ref num3))
            {
                num3 = 1;
            }
            if (!this.calendarStartDate2.SelectedDate.HasValue)
            {
                this.ShowMsg("请输入正确的生效时间!", false);
            }
            if (!this.calendarEndDate2.SelectedDate.HasValue)
            {
                this.ShowMsg("请输入正确的过期时间!", false);
            }
            if (num3 >= num2)
            {
                this.ShowMsg("每人限领数量不能大于或者等于总发放量!", false);
            }
            else
            {
                CouponEdit coupon = new CouponEdit
                {
                    maxReceivNum = new int?(num3),
                    totalNum     = new int?(num2),
                    begin        = this.calendarStartDate2.SelectedDate,
                    end          = this.calendarEndDate2.SelectedDate
                };
                string msg  = "";
                string str2 = CouponHelper.UpdateCoupon(i, coupon, ref msg);
                if (this.txt_used.Text == "true")
                {
                    CouponHelper.setCouponFinished(i, !bFininshed);
                    this.txt_used.Text = "";
                    this.BindData();
                    this.ShowMsg("启用优惠券成功!", true);
                }
                else if (str2 == "1")
                {
                    this.ShowMsgAndReUrl("编辑优惠券成功!", true, this.reUrl);
                }
                else
                {
                    this.ShowMsg(str2, false);
                }
            }
        }
Example #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(Page.Request.QueryString["couponId"], out couponId))
     {
         base.GotoResourceNotFound();
     }
     else
     {
         btnEditCoupons.Click += new EventHandler(btnEditCoupons_Click);
         if (!Page.IsPostBack)
         {
             CouponInfo coupon = CouponHelper.GetCoupon(couponId);
             if (coupon == null)
             {
                 base.GotoResourceNotFound();
             }
             else
             {
                 Globals.EntityCoding(coupon, false);
                 lblEditCouponId.Text = coupon.CouponId.ToString();
                 txtCouponName.Text   = coupon.Name;
                 if (coupon.Amount.HasValue)
                 {
                     txtAmount.Text = string.Format("{0:F2}", coupon.Amount);
                 }
                 txtDiscountValue.Text        = coupon.DiscountValue.ToString("F2");
                 calendarEndDate.SelectedDate = new DateTime?(coupon.ClosingTime);
                 txtNeedPoint.Text            = coupon.NeedPoint.ToString();
             }
         }
     }
 }