Пример #1
0
        private void ReceiveVouchers(System.Web.HttpContext context)
        {
            string text = "";

            if (context.Request["voucherid"] != null)
            {
                text = context.Request["voucherid"].ToString();
            }
            Member member = HiContext.Current.User as Member;

            if (member == null)
            {
                this.message = "你还未登陆,请登陆";
                return;
            }
            int voucherid = 0;

            if (!int.TryParse(text, out voucherid))
            {
                this.message = "该链接无效";
                return;
            }

            VoucherInfo voucherInfo = VoucherHelper.GetVoucher(voucherid);

            if (voucherInfo == null || voucherInfo.SendType != 3 || voucherInfo.StartTime.Date > DateTime.Now.Date || voucherInfo.ClosingTime < DateTime.Now.Date)
            {
                this.message = "该链接无效";
                return;
            }

            int count = VoucherHelper.GetCountVoucherItem(voucherid, member.UserId);

            if (count == 0)
            {
                string claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                string          password        = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                DateTime        deadline        = DateTime.Now.AddDays(voucherInfo.Validity);
                VoucherItemInfo voucherItemInfo = new VoucherItemInfo(voucherid, claimCode, password, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, deadline);

                IList <VoucherItemInfo> voucherItemList = new List <VoucherItemInfo>();
                voucherItemList.Add(voucherItemInfo);
                if (VoucherHelper.SendClaimCodes(voucherItemList))
                {
                    this.message = "你已成功领取该优惠券";
                }

                else
                {
                    this.message = "操作失败";
                }
            }
            else
            {
                this.message = "您已经领过该优惠券";
            }
        }
Пример #2
0
        /// <summary>
        /// 注册赠送现金券
        /// </summary>
        /// <param name="members"></param>
        protected void RegistSendVoucher(IList <Member> members)
        {
            IList <VoucherInfo> voucherList = VoucherHelper.GetVoucherBySendType(2);

            IList <VoucherItemInfo> list = new System.Collections.Generic.List <VoucherItemInfo>();

            string claimCode = string.Empty;
            string password  = string.Empty;

            if (voucherList.Count > 0)
            {
                foreach (Member member in members)
                {
                    foreach (VoucherInfo voucher in voucherList)
                    {
                        VoucherItemInfo item = new VoucherItemInfo();
                        if (VoucherHelper.GetCountVoucherItem(voucher.VoucherId, member.UserId) > 0)
                        {
                            continue;
                        }
                        else
                        {
                            claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                            claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                            password  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                            item      = new VoucherItemInfo(voucher.VoucherId, claimCode, password, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, DateTime.Now.AddDays(voucher.Validity));
                            list.Add(item);
                        }
                    }
                }
            }

            if (list.Count > 0)
            {
                try
                {
                    VoucherHelper.SendClaimCodes(list);
                }

                catch
                {
                }
            }
        }
Пример #3
0
        private void btnSend_Click(object sender, System.EventArgs e)
        {
            VoucherInfo     voucherInfo = VoucherHelper.GetVoucher(voucherId);
            DateTime        deadline    = DateTime.Now.AddDays(voucherInfo.Validity);
            VoucherItemInfo item        = new VoucherItemInfo();

            System.Collections.Generic.IList <VoucherItemInfo> list  = new System.Collections.Generic.List <VoucherItemInfo>();
            System.Collections.Generic.IList <Member>          list2 = new System.Collections.Generic.List <Member>();
            if (this.rdoName.Checked)
            {
                if (!string.IsNullOrEmpty(this.txtMemberNames.Text.Trim()))
                {
                    System.Collections.Generic.IList <string> list3 = new System.Collections.Generic.List <string>();
                    string   text  = this.txtMemberNames.Text.Trim().Replace("\r\n", "\n");
                    string[] array = text.Replace("\n", "*").Split(new char[]
                    {
                        '*'
                    });
                    for (int i = 0; i < array.Length; i++)
                    {
                        list3.Add(array[i]);
                    }
                    list2 = PromoteHelper.GetMemdersByNames(list3);
                }
                string claimCode = string.Empty;
                string password  = string.Empty;
                foreach (Member current in list2)
                {
                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                    password  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    item      = new VoucherItemInfo(this.voucherId, claimCode, password, new int?(current.UserId), current.Username, current.Email, System.DateTime.Now, deadline);
                    list.Add(item);
                }
                if (list.Count <= 0)
                {
                    this.ShowMsg("你输入的会员名中没有一个正确的,请输入正确的会员名", false);
                    return;
                }
                VoucherHelper.SendClaimCodes(list);
                this.txtMemberNames.Text = string.Empty;
                this.ShowMsg(string.Format("此次发送操作已成功,现金券发送数量:{0}", list.Count), true);
            }
            if (this.rdoRank.Checked)
            {
                StringBuilder strcondition = new StringBuilder();
                strcondition.Append("1=1");
                if (this.rankList.SelectedValue > 0)
                {
                    strcondition.AppendFormat(" and GradeId={0} ", this.rankList.SelectedValue);
                }

                if (this.registerFromDate.SelectedDate.HasValue && this.registerToDate.SelectedDate.HasValue)
                {
                    strcondition.AppendFormat(" and CreateDate>='{0}' and CreateDate<='{1}' ", this.registerFromDate.SelectedDate.Value, this.registerToDate.SelectedDate.Value);
                }

                if (this.ddlReggion.GetSelectedRegionId().HasValue)
                {
                    strcondition.AppendFormat(" and TopRegionId={0} ", this.ddlReggion.GetSelectedRegionId().Value);
                }


                list2 = PromoteHelper.GetMembersByCondition(strcondition.ToString());
                string claimCode2 = string.Empty;
                string password2  = string.Empty;
                foreach (Member current2 in list2)
                {
                    claimCode2 = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    claimCode2 = Sign(claimCode2, "UTF-8").Substring(8, 16);
                    password2  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                    item       = new VoucherItemInfo(this.voucherId, claimCode2, password2, new int?(current2.UserId), current2.Username, current2.Email, System.DateTime.Now, deadline);
                    list.Add(item);
                }
                if (list.Count <= 0)
                {
                    this.ShowMsg("您选择的条件下面没有符合条件的会员", false);
                    return;
                }
                VoucherHelper.SendClaimCodes(list);
                this.txtMemberNames.Text = string.Empty;
                this.ShowMsg(string.Format("此次发送操作已成功,现金券发送数量:{0}", list.Count), true);
            }
        }
Пример #4
0
        private void OrderSendVoucher(IList <OrderInfo> orderList)
        {
            IList <VoucherInfo> voucherList = VoucherHelper.GetVoucherBySendType(1);

            IList <VoucherItemInfo> list = new System.Collections.Generic.List <VoucherItemInfo>();

            string claimCode = string.Empty;
            string password  = string.Empty;

            if (voucherList.Count > 0)
            {
                foreach (OrderInfo orderInfo in orderList)
                {
                    foreach (VoucherInfo voucher in voucherList)
                    {
                        VoucherItemInfo item = new VoucherItemInfo();
                        ///不存在拆单
                        if (String.IsNullOrEmpty(orderInfo.SourceOrderId))
                        {
                            if (VoucherHelper.GetCountVoucherItem(voucher.VoucherId, orderInfo.OrderId) > 0)
                            {
                                continue;
                            }
                            else
                            {
                                if (orderInfo.Amount >= Convert.ToDecimal(voucher.SendTypeItem))
                                {
                                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                                    claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                                    password  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                                    item      = new VoucherItemInfo(orderInfo.OrderId, voucher.VoucherId, claimCode, password, new int?(orderInfo.UserId), orderInfo.Username, orderInfo.EmailAddress, System.DateTime.Now, DateTime.Now.AddDays(voucher.Validity));
                                    list.Add(item);
                                }
                            }
                        }
                        //拆单
                        else
                        {
                            if (VoucherHelper.GetCountVoucherItem(voucher.VoucherId, orderInfo.SourceOrderId) > 0)
                            {
                                continue;
                            }
                            else
                            {
                                decimal sourceAmount = OrderHelper.GetOrderAmount(orderInfo.SourceOrderId);
                                if (sourceAmount >= Convert.ToDecimal(voucher.SendTypeItem))
                                {
                                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                                    claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                                    password  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                                    item      = new VoucherItemInfo(orderInfo.SourceOrderId, voucher.VoucherId, claimCode, password, new int?(orderInfo.UserId), orderInfo.Username, orderInfo.EmailAddress, System.DateTime.Now, DateTime.Now.AddDays(voucher.Validity));
                                    list.Add(item);
                                }
                            }
                        }
                    }
                }
            }

            if (list.Count > 0)
            {
                try
                {
                    VoucherHelper.SendClaimCodes(list);
                }

                catch
                {
                }
            }
        }
Пример #5
0
        protected override void AttachChildControls()
        {
            this.vVoucherImage = (VVoucherImage)this.FindControl("vVoucherImage");

            string nowKeyCode = "";

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["k"]))
            {
                nowKeyCode = this.Page.Request.QueryString["k"];
            }
            else
            {
                if (this.vVoucherImage != null)
                {
                    vVoucherImage.Visible = false;
                }
            }
            string k = "8c0f9f7b58864063bd83cffeb9624915";
            int    voucherItemsCount = 0;

            if (nowKeyCode != k)
            {
                if (this.vVoucherImage != null)
                {
                    vVoucherImage.Visible = false;
                }
            }
            else
            {
                Member member = HiContext.Current.User as Member;

                voucherItemsCount = VoucherHelper.GetVoucherItemsCount(member.UserId, nowKeyCode);

                if (voucherItemsCount == 0)
                {
                    //通过发送方式获取优惠券列表(3为自助领劵)
                    IList <VoucherInfo> voucherList = VoucherHelper.GetVoucherBySendType(3);

                    //1.看是否登录,就是判断有没有userId,获取openId;2.往Ecshop_VoucherItems插入记录
                    VoucherItemInfo         item = new VoucherItemInfo();
                    IList <VoucherItemInfo> list = new List <VoucherItemInfo>();

                    string   claimCode = string.Empty;
                    string   password  = string.Empty;
                    DateTime deadline;

                    foreach (VoucherInfo current in voucherList)
                    {
                        deadline  = DateTime.Today.AddDays(current.Validity);
                        claimCode = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                        claimCode = Sign(claimCode, "UTF-8").Substring(8, 16);
                        password  = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                        item      = new VoucherItemInfo(current.VoucherId, claimCode, password, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, deadline, nowKeyCode);
                        list.Add(item);
                    }

                    VoucherHelper.BulkAddVoucherItems(list);
                }

                voucherItemsCount = VoucherHelper.GetVoucherItemsCount(member.UserId, nowKeyCode);
            }

            if (voucherItemsCount > 0)
            {
                //显示页面
                if (this.vVoucherImage != null)
                {
                    //可见
                    vVoucherImage.Visible = true;
                }
            }
            else
            {
                //否则隐藏
                if (this.vVoucherImage != null)
                {
                    vVoucherImage.Visible = false;
                }
            }

            //string.Format("此次发送操作已成功,现金券发送数量:{0}", list.Count);
            PageTitle.AddSiteNameTitle("发送优惠券");
        }