コード例 #1
0
        protected override void AttachChildControls()
        {
            this.litAD = (System.Web.UI.WebControls.Literal) this.FindControl("litAD");
            IList <CouponInfo> couponList = CouponHelper.GetCouponsBySendType(5);

            if (couponList != null && couponList.Count > 0)
            {
                litAD.Text = "True";
            }
            PageTitle.AddSiteNameTitle("绑定手机号码");
        }
コード例 #2
0
        /// <summary>
        /// 微信新用户注册用60元大礼包,在活动页面手动领取
        /// </summary>
        /// <param name="context"></param>
        private void GetRegisterCoupons(System.Web.HttpContext context)
        {
            Member member = HiContext.Current.User as Member;

            if (member == null)
            {
                this.message = "{\"Success\":false,\"Message\":\"你还未登陆,请登陆\"}";
                return;
            }

            int count = CouponHelper.GetCountCouponItemed(member.UserId, 3);

            if (count == 0)
            {
                IList <CouponInfo>     couponList     = CouponHelper.GetCouponsBySendType(3);
                IList <CouponItemInfo> couponItemList = new List <CouponItemInfo>();
                string claimCode = string.Empty;
                if (couponList != null && couponList.Count > 0)
                {
                    foreach (CouponInfo coupon in couponList)
                    {
                        CouponItemInfo item = new CouponItemInfo();
                        claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                        item      = new CouponItemInfo(coupon.CouponId, claimCode, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, coupon.StartTime, coupon.ClosingTime, coupon.Amount, coupon.DiscountValue);
                        couponItemList.Add(item);
                    }
                }
                else
                {
                    this.message = "{\"Success\":false,\"Message\":\"没有可以领取的优惠券\"}";
                    return;
                }
                if (CouponHelper.SendClaimCodes(couponItemList))
                {
                    this.message = "{\"Success\":true,\"Message\":\"成功领取该优惠券\"}";
                }

                else
                {
                    this.message = "{\"Success\":false,\"Message\":\"该优惠卷无效\"}";
                }
            }
            else
            {
                this.message = "{\"Success\":false,\"Message\":\"您已经领过该优惠券\"}";
            }
        }
コード例 #3
0
        /// <summary>
        /// 新用户注册赠送优惠券
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public static bool NewUserSendRegisterCoupon(Member member)
        {
            ErrorLog.Write("Begin优惠券");
            bool Flag  = true;
            int  count = CouponHelper.GetCountCouponItemed(member.UserId, 5);

            if (count == 0)
            {
                // 获取有效时间内注册赠劵的数量
                IList <CouponInfo>     couponList     = CouponHelper.GetCouponsBySendType(5);
                IList <CouponItemInfo> couponItemList = new List <CouponItemInfo>();
                string claimCode = string.Empty;
                if (couponList != null && couponList.Count > 0)
                {
                    foreach (CouponInfo coupon in couponList)
                    {
                        ErrorLog.Write("开始进入优惠券1:Validity:" + coupon.Validity + ";Createdate:" + member.CreateDate + ";StartTime:" + coupon.StartTime + "");
                        CouponItemInfo item = new CouponItemInfo();
                        claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                        if (coupon.Validity > 0 && member.CreateDate >= coupon.StartTime)
                        {
                            ErrorLog.Write("开始进入优惠券2:Validity:" + coupon.Validity + ";Createdate:" + member.CreateDate + ";StartTime:" + coupon.StartTime + "");
                            coupon.StartTime   = member.CreateDate;
                            coupon.ClosingTime = member.CreateDate.AddDays(coupon.Validity);
                        }
                        else if (coupon.Validity > 0 && member.CreateDate < coupon.StartTime)
                        {
                            coupon.StartTime   = DateTime.Now;
                            coupon.ClosingTime = DateTime.Now.AddDays(coupon.Validity);
                        }
                        ErrorLog.Write("开始进入优惠券3:Validity:" + coupon.Validity + ";StartTime:" + coupon.StartTime + ";ClosingTime:" + coupon.ClosingTime + "");
                        item = new CouponItemInfo(coupon.CouponId, claimCode, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, coupon.StartTime.Date, coupon.ClosingTime.Date.AddDays(1).AddSeconds(-1), coupon.Amount, coupon.DiscountValue);
                        couponItemList.Add(item);
                    }
                }
                if (couponItemList.Count > 0)
                {
                    Flag = CouponHelper.SendClaimCodes(couponItemList);
                }
                ErrorLog.Write("End优惠券");
            }
            return(Flag);
        }
コード例 #4
0
        /// <summary>
        /// 注册赠送优惠券
        /// </summary>
        /// <param name="members"></param>
        protected void RegistSendCoupon(IList <Member> members)
        {
            IList <CouponInfo> couponList = CouponHelper.GetCouponsBySendType(2);

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

            string claimCode = string.Empty;

            if (couponList.Count > 0)
            {
                foreach (Member member in members)
                {
                    foreach (CouponInfo coupon in couponList)
                    {
                        CouponItemInfo item = new CouponItemInfo();
                        if (CouponHelper.GetCountCouponItem(coupon.CouponId, member.UserId) > 0)
                        {
                            continue;
                        }
                        else
                        {
                            claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                            item      = new CouponItemInfo(coupon.CouponId, claimCode, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, coupon.StartTime, coupon.ClosingTime, coupon.Amount, coupon.DiscountValue);
                            list.Add(item);
                        }
                    }
                }
            }

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

                catch
                {
                }
            }
        }
コード例 #5
0
        private void OrderSendCoupon(IList <OrderInfo> orderList)
        {
            IList <CouponInfo> couponList = CouponHelper.GetCouponsBySendType(1);

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

            string claimCode = string.Empty;

            if (couponList.Count > 0)
            {
                foreach (OrderInfo orderInfo in orderList)
                {
                    foreach (CouponInfo coupon in couponList)
                    {
                        CouponItemInfo item = new CouponItemInfo();
                        if (String.IsNullOrEmpty(orderInfo.SourceOrderId))
                        {
                            if (CouponHelper.GetCountCouponItem(coupon.CouponId, orderInfo.OrderId) > 0)
                            {
                                continue;
                            }
                            else
                            {
                                if (orderInfo.Amount >= Convert.ToDecimal(coupon.SendTypeItem))
                                {
                                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                                    item      = new CouponItemInfo(coupon.CouponId, claimCode, new int?(orderInfo.UserId), orderInfo.Username, orderInfo.EmailAddress, System.DateTime.Now, orderInfo.OrderId);
                                    list.Add(item);
                                }
                            }
                        }

                        else
                        {
                            if (CouponHelper.GetCountCouponItem(coupon.CouponId, orderInfo.SourceOrderId) > 0)
                            {
                                continue;
                            }
                            else
                            {
                                decimal sourceAmount = OrderHelper.GetOrderAmount(orderInfo.SourceOrderId);
                                if (sourceAmount >= Convert.ToDecimal(coupon.SendTypeItem))
                                {
                                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                                    item      = new CouponItemInfo(coupon.CouponId, claimCode, new int?(orderInfo.UserId), orderInfo.Username, orderInfo.EmailAddress, System.DateTime.Now, orderInfo.SourceOrderId);
                                    list.Add(item);
                                }
                            }
                        }
                    }
                }
            }

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

                catch
                {
                }
            }
        }
コード例 #6
0
        public static bool UpdateUserNameCoupon(Member member, string recemmendCode, out bool IsSendCoupon)
        {
            IsSendCoupon = false;
            bool     flag     = false;
            Database database = DatabaseFactory.CreateDatabase();

            using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
            {
                dbConnection.Open();
                System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                try
                {
                    // 判断是否有邀请码
                    if (!string.IsNullOrWhiteSpace(recemmendCode))
                    {
                        string sourcechars    = ConfigurationManager.AppSettings["sourcechars"];
                        string newsourcechars = ConfigurationManager.AppSettings["newsourcechars"];
                        if (!string.IsNullOrWhiteSpace(sourcechars) && !string.IsNullOrWhiteSpace(newsourcechars))
                        {
                            string currcode = BaseConvertHelper.BaseConvert(recemmendCode, newsourcechars, sourcechars);
                            string useredId = MemberHelper.GetUserIdByRecommendCode(currcode);
                            if (!string.IsNullOrWhiteSpace(useredId) && !string.IsNullOrWhiteSpace(currcode))
                            {
                                // 插入到邀请码记录表
                                if (!MemberHelper.AddRecommendCodeRecord(member.UserId, Convert.ToInt32(useredId), currcode, recemmendCode))
                                {
                                    dbTransaction.Rollback();
                                    flag = false;
                                    return(flag);
                                }
                            }
                        }
                    }
                    bool CouponFlag = true;
                    // 判断该手机号码是否有openid
                    if (!UserHelper.IsExistOpendByUserName(member.Username))
                    {
                        CouponFlag = false;
                    }
                    //if (Users.UpdateUser(member))
                    if (!UserHelper.UpdateUserUserNameByCellPhone(member.UserId, member.Username, member.CellPhone, member.Password, member.OpenId, 1, UserHelper.CreateSalt()))
                    {
                        dbTransaction.Rollback();
                        flag = false;
                        return(flag);
                    }
                    if (CouponFlag)
                    {
                        // 判断是否有优惠卷
                        int count = CouponHelper.GetCountCouponItemed(member.UserId, 5);
                        if (count == 0)
                        {
                            // 获取有效时间内注册赠劵的数量
                            IList <CouponInfo>     couponList     = CouponHelper.GetCouponsBySendType(5);
                            IList <CouponItemInfo> couponItemList = new List <CouponItemInfo>();
                            string claimCode = string.Empty;
                            if (couponList != null && couponList.Count > 0)
                            {
                                foreach (CouponInfo coupon in couponList)
                                {
                                    CouponItemInfo item = new CouponItemInfo();
                                    claimCode = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);

                                    if (coupon.Validity > 0 && member.CreateDate >= coupon.StartTime)
                                    {
                                        coupon.StartTime   = member.CreateDate;
                                        coupon.ClosingTime = member.CreateDate.AddDays(coupon.Validity);
                                    }
                                    else if (coupon.Validity > 0 && member.CreateDate < coupon.StartTime)
                                    {
                                        coupon.StartTime   = DateTime.Now;
                                        coupon.ClosingTime = DateTime.Now.AddDays(coupon.Validity);
                                    }
                                    item = new CouponItemInfo(coupon.CouponId, claimCode, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, coupon.StartTime.Date, coupon.ClosingTime.Date.AddDays(1).AddSeconds(-1), coupon.Amount, coupon.DiscountValue);
                                    couponItemList.Add(item);
                                }
                            }
                            if (couponItemList.Count > 0)
                            {
                                // 发劵
                                if (!CouponHelper.SendClaimCodes(couponItemList))
                                {
                                    dbTransaction.Rollback();
                                    flag = false;
                                    return(flag);
                                }
                                else
                                {
                                    IsSendCoupon = true;
                                }
                            }
                        }
                    }
                    dbTransaction.Commit();
                    flag = true;
                }
                catch
                {
                    dbTransaction.Rollback();
                    flag = false;
                }
                finally
                {
                    dbConnection.Close();
                }
            }
            return(flag);
        }