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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(RedEnvelopeGetRecordQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                PageModel <WeiXinRedEnvelopeInfo> weiXinRedEnvelope = WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(query);
                dataGridViewModel.rows  = new List <Dictionary <string, object> >();
                dataGridViewModel.total = weiXinRedEnvelope.Total;
                foreach (WeiXinRedEnvelopeInfo model in weiXinRedEnvelope.Models)
                {
                    model.ActualNumber = WeiXinRedEnvelopeProcessor.GetActualNumber(model.Id);
                    Dictionary <string, object> dictionary = model.ToDictionary();
                    string value = "";
                    switch (model.State)
                    {
                    case 1:
                        value = "已开启";
                        break;

                    case 0:
                        value = "已关闭";
                        break;

                    case 2:
                        value = "已过期";
                        break;
                    }
                    dictionary.Add("StatusText", value);
                    dataGridViewModel.rows.Add(dictionary);
                }
            }
            return(dataGridViewModel);
        }
Exemplo n.º 3
0
        public void CopyRedEnvelope(string openId, MemberInfo memberInfo)
        {
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("OpenId", openId);
            dictionary.Add("UserName", memberInfo.UserName);
            try
            {
                IList <RedEnvelopeGetRecordInfo> list = WeiXinRedEnvelopeProcessor.GettWaitToUserRedEnvelopeGetRecord(openId);
                if (list == null || list.Count == 0)
                {
                    dictionary.Add("RedEnvelopeErrMsg", "红包记录为空");
                }
                int num = 1;
                foreach (RedEnvelopeGetRecordInfo item in list)
                {
                    WeiXinRedEnvelopeInfo weiXinRedEnvelope = WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(item.RedEnvelopeId);
                    if (weiXinRedEnvelope == null)
                    {
                        dictionary.Add("RedEnvelopeErrMsg" + num, "红包信息为空" + item.RedEnvelopeId.ToNullString());
                    }
                    else
                    {
                        CouponItemInfo couponItemInfo = new CouponItemInfo();
                        couponItemInfo.UserId             = memberInfo.UserId;
                        couponItemInfo.UserName           = memberInfo.UserName;
                        couponItemInfo.CanUseProducts     = "";
                        couponItemInfo.ClosingTime        = weiXinRedEnvelope.EffectivePeriodEndTime;
                        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);
                            if (couponActionStatus != 0)
                            {
                                dictionary.Add("SendDiffentTypeClaimCodesErrMsg" + num, "发送优惠券失败-" + couponActionStatus.ToString());
                            }
                            num++;
                        }
                        else
                        {
                            dictionary.Add("SetRedEnvelopeGetRecordToMemberErrMsg" + num, "设置红包记录给会员失败");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Globals.WriteExceptionLog(ex, dictionary, "RedEnvelope");
            }
        }
Exemplo n.º 4
0
 public static CouponActionStatus AddRedEnvelopeItemInfo(CouponItemInfo couponItemInfo)
 {
     if (!couponItemInfo.RedEnvelopeId.HasValue || WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(couponItemInfo.RedEnvelopeId.Value) == null)
     {
         return(CouponActionStatus.NotExists);
     }
     if (couponItemInfo.UserId <= 0)
     {
         return(CouponActionStatus.InconsistentInformationUser);
     }
     if (string.IsNullOrEmpty(couponItemInfo.ClaimCode))
     {
         couponItemInfo.ClaimCode = Guid.NewGuid().ToString();
     }
     return(new WeiXinRedEnvelopeDao().AddWeiXinRedEnvelopeToUser(couponItemInfo));
 }
Exemplo n.º 5
0
        private bool CheckRedEnvelope(string sendCode, string orderId)
        {
            if (string.IsNullOrEmpty(sendCode))
            {
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=发送码错误", true);
            }
            if (string.IsNullOrEmpty(orderId))
            {
                NameValueCollection nameValueCollection = new NameValueCollection
                {
                    this.Context.Request.QueryString,
                    this.Context.Request.Form
                };
                nameValueCollection.Add("OrderId1", orderId);
                nameValueCollection.Add("sendCode1", sendCode);
                Globals.AppendLog(nameValueCollection, "", "", "", "CheckRedEnvelope");
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=订单编号为空", true);
            }
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(orderId);

            if (orderInfo == null)
            {
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=订单不存在", true);
            }
            RedEnvelopeSendRecord redEnvelopeSendRecord = WeiXinRedEnvelopeProcessor.GetRedEnvelopeSendRecord(Guid.Parse(sendCode), orderId, "");

            if (redEnvelopeSendRecord == null)
            {
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=发送码不存在", true);
            }
            this.weiXinRedEnvelope = WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(redEnvelopeSendRecord.RedEnvelopeId.Value);
            if (this.weiXinRedEnvelope == null)
            {
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=红包活动已经被删除", true);
            }
            if (this.weiXinRedEnvelope.State == 0)
            {
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=红包活动已经关闭", true);
            }
            DateTime now = DateTime.Now;

            if (now > this.weiXinRedEnvelope.ActiveStartTime && this.weiXinRedEnvelope.ActiveEndTime < now)
            {
                this.Page.Response.Redirect("/Vshop/RedEnvelopeError?errorInfo=红包活动没有开始或已过期", true);
            }
            return(true);
        }
Exemplo n.º 6
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(RedEnvelopeGetRecordQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                PageModel <RedEnvelopeGetRecordInfo> redEnvelopeGetRecord = WeiXinRedEnvelopeProcessor.GetRedEnvelopeGetRecord(query);
                dataGridViewModel.rows  = new List <Dictionary <string, object> >();
                dataGridViewModel.total = redEnvelopeGetRecord.Total;
                foreach (RedEnvelopeGetRecordInfo model in redEnvelopeGetRecord.Models)
                {
                    Dictionary <string, object> dictionary = model.ToDictionary();
                    string text = "";
                    WeiXinRedEnvelopeInfo weiXinRedEnvelope = WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(model.RedEnvelopeId);
                    text = ((weiXinRedEnvelope == null) ? "未知" : weiXinRedEnvelope.Name);
                    dictionary.Add("RedEnvelopeName", text);
                    dataGridViewModel.rows.Add(dictionary);
                }
            }
            return(dataGridViewModel);
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = this.Page.Request["RedEnvelopeId"].ToInt(0);
            WeiXinRedEnvelopeInfo       weiXinRedEnvelope = WeiXinRedEnvelopeProcessor.GetWeiXinRedEnvelope(id);
            Dictionary <string, object> calendarParameter = this.txtActiveStartTime.CalendarParameter;
            DateTime dateTime = DateTime.Now;

            calendarParameter.Add("startDate", dateTime.ToString("yyyy-MM-dd"));
            Dictionary <string, object> calendarParameter2 = this.txtActiveEndTime.CalendarParameter;

            dateTime = DateTime.Now;
            calendarParameter2.Add("startDate", dateTime.ToString("yyyy-MM-dd"));
            Dictionary <string, object> calendarParameter3 = this.txtEffectivePeriodStartTime.CalendarParameter;

            dateTime = DateTime.Now;
            calendarParameter3.Add("startDate", dateTime.ToString("yyyy-MM-dd"));
            Dictionary <string, object> calendarParameter4 = this.txtEffectivePeriodEndTime.CalendarParameter;

            dateTime = DateTime.Now;
            calendarParameter4.Add("startDate", dateTime.ToString("yyyy-MM-dd"));
            if (weiXinRedEnvelope == null)
            {
                base.GotoResourceNotFound();
            }
            else
            {
                CalendarPanel calendarPanel = this.txtActiveEndTime;
                dateTime           = weiXinRedEnvelope.ActiveEndTime;
                calendarPanel.Text = dateTime.ToString("yyyy-MM-dd");
                CalendarPanel calendarPanel2 = this.txtActiveStartTime;
                dateTime            = weiXinRedEnvelope.ActiveStartTime;
                calendarPanel2.Text = dateTime.ToString("yyyy-MM-dd");
                CalendarPanel calendarPanel3 = this.txtEffectivePeriodEndTime;
                dateTime            = weiXinRedEnvelope.EffectivePeriodEndTime;
                calendarPanel3.Text = dateTime.ToString("yyyy-MM-dd");
                CalendarPanel calendarPanel4 = this.txtEffectivePeriodStartTime;
                dateTime            = weiXinRedEnvelope.EffectivePeriodStartTime;
                calendarPanel4.Text = dateTime.ToString("yyyy-MM-dd");
                this.txtEnableIssueMinAmount.Text = weiXinRedEnvelope.EnableIssueMinAmount.F2ToString("f2");
                this.txtEnableUseMinAmount.Text   = weiXinRedEnvelope.EnableUseMinAmount.F2ToString("f2");
                this.txtMaxAmount.Text            = weiXinRedEnvelope.MaxAmount.F2ToString("f2");
                this.txtMaxNumber.Text            = weiXinRedEnvelope.MaxNumber.F2ToString("f2");
                this.txtName.Text         = weiXinRedEnvelope.Name;
                this.txtShareDetails.Text = weiXinRedEnvelope.ShareDetails;
                this.txtShareTitle.Text   = weiXinRedEnvelope.ShareTitle;
                if (weiXinRedEnvelope.EnableUseMinAmount > decimal.Zero)
                {
                    this.rdbSatisfy.Checked   = true;
                    this.rdbUnlimited.Checked = false;
                }
                else
                {
                    this.divSatisfy.Visible   = false;
                    this.rdbSatisfy.Checked   = false;
                    this.rdbUnlimited.Checked = true;
                }
                if (weiXinRedEnvelope.Type == 1.GetHashCode())
                {
                    this.random.Visible        = false;
                    this.one.Visible           = true;
                    this.rdbTypeFixed.Checked  = true;
                    this.rdbTypeRandom.Checked = false;
                    this.txtAmountFixed.Text   = weiXinRedEnvelope.MinAmount.F2ToString("f2");
                }
                else
                {
                    this.random.Visible        = true;
                    this.one.Visible           = false;
                    this.rdbTypeFixed.Checked  = false;
                    this.rdbTypeRandom.Checked = true;
                    this.txtMinAmount.Text     = weiXinRedEnvelope.MinAmount.F2ToString("f2");
                    this.txtMaxAmount.Text     = weiXinRedEnvelope.MaxAmount.F2ToString("f2");
                }
            }
        }