예제 #1
0
        private void GetSupplierCoupons(System.Web.HttpContext context)
        {
            string text = "";

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

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

            if (!int.TryParse(text, out couponid))
            {
                this.message = "{\"Success\":false,\"Message\":\"该优惠卷无效\"}";
                return;
            }

            CouponInfo couponInfo = CouponHelper.GetCoupon(couponid);

            if (couponInfo == null || couponInfo.ClosingTime < DateTime.Now.Date)
            {
                this.message = "{\"Success\":false,\"Message\":\"该优惠卷无效\"}";
                return;
            }

            int count = CouponHelper.GetCountCouponItem(couponid, member.UserId);

            if (count == 0)
            {
                string         claimCode      = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                CouponItemInfo couponItemInfo = new CouponItemInfo(couponid, claimCode, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, couponInfo.StartTime, couponInfo.ClosingTime, couponInfo.Amount, couponInfo.DiscountValue);

                IList <CouponItemInfo> couponItemList = new List <CouponItemInfo>();
                couponItemList.Add(couponItemInfo);
                if (CouponHelper.SendClaimCodes(couponItemList))
                {
                    this.message = "{\"Success\":true,\"Message\":\"成功领取该优惠券\"}";
                }

                else
                {
                    this.message = "{\"Success\":false,\"Message\":\"该优惠卷无效\"}";
                }
            }
            else
            {
                this.message = "{\"Success\":false,\"Message\":\"您已经领过该优惠券\"}";
            }
        }
예제 #2
0
        private void ReceiveCoupons(System.Web.HttpContext context)
        {
            string text = "";

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

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

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

            CouponInfo couponInfo = CouponHelper.GetCoupon(couponid);

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

            int count = CouponHelper.GetCountCouponItem(couponid, member.UserId);

            if (count == 0)
            {
                string         claimCode      = System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 15);
                CouponItemInfo couponItemInfo = new CouponItemInfo(couponid, claimCode, new int?(member.UserId), member.Username, member.Email, System.DateTime.Now, couponInfo.StartTime, couponInfo.ClosingTime, couponInfo.Amount, couponInfo.DiscountValue);

                IList <CouponItemInfo> couponItemList = new List <CouponItemInfo>();
                couponItemList.Add(couponItemInfo);
                if (CouponHelper.SendClaimCodes(couponItemList))
                {
                    this.message = "你已成功领取该优惠券";
                }

                else
                {
                    this.message = "操作失败";
                }
            }
            else
            {
                this.message = "您已经领过该优惠券";
            }
        }
예제 #3
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
                {
                }
            }
        }
예제 #4
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
                {
                }
            }
        }