public static CouponActionStatus UserGetCoupon(MemberInfo user, int couponId)
        {
            CouponInfo eFCoupon = CouponHelper.GetEFCoupon(couponId);

            if (eFCoupon == null)
            {
                return(CouponActionStatus.NotExists);
            }
            if (user == null)
            {
                return(CouponActionStatus.InconsistentInformationUser);
            }
            if (eFCoupon.ClosingTime < DateTime.Now)
            {
                return(CouponActionStatus.Overdue);
            }
            if (eFCoupon.ObtainWay != 0)
            {
                return(CouponActionStatus.CanNotGet);
            }
            int couponSurplus = CouponHelper.GetCouponSurplus(couponId);

            if (couponSurplus <= 0)
            {
                return(CouponActionStatus.InadequateInventory);
            }
            int couponObtainNum = CouponHelper.GetCouponObtainNum(couponId, user.UserId);

            if (couponObtainNum >= eFCoupon.UserLimitCount && eFCoupon.UserLimitCount > 0)
            {
                return(CouponActionStatus.CannotReceive);
            }
            CouponItemInfo couponItemInfo = new CouponItemInfo();

            couponItemInfo.UserId             = user.UserId;
            couponItemInfo.UserName           = user.UserName;
            couponItemInfo.CanUseProducts     = eFCoupon.CanUseProducts;
            couponItemInfo.CouponId           = eFCoupon.CouponId;
            couponItemInfo.CouponName         = eFCoupon.CouponName;
            couponItemInfo.OrderUseLimit      = eFCoupon.OrderUseLimit;
            couponItemInfo.Price              = eFCoupon.Price;
            couponItemInfo.StartTime          = eFCoupon.StartTime;
            couponItemInfo.ClosingTime        = eFCoupon.ClosingTime;
            couponItemInfo.UseWithGroup       = eFCoupon.UseWithGroup;
            couponItemInfo.UseWithPanicBuying = eFCoupon.UseWithPanicBuying;
            couponItemInfo.UseWithFireGroup   = eFCoupon.UseWithFireGroup;
            couponItemInfo.ClaimCode          = Guid.NewGuid().ToString();
            couponItemInfo.GetDate            = DateTime.Now;
            return(CouponHelper.AddCouponItem(couponItemInfo));
        }
        public static CouponActionStatus AddCouponItemInfo(CouponItemInfo couponItemInfo)
        {
            if (couponItemInfo.CouponId < 0)
            {
                return(CouponActionStatus.NotExists);
            }
            CouponInfo eFCoupon = CouponHelper.GetEFCoupon(couponItemInfo.CouponId);

            if (eFCoupon == null)
            {
                return(CouponActionStatus.NotExists);
            }
            if (eFCoupon.ClosingTime < DateTime.Now)
            {
                return(CouponActionStatus.Overdue);
            }
            if (couponItemInfo.UserId <= 0)
            {
                return(CouponActionStatus.InconsistentInformationUser);
            }
            int couponSurplus = CouponHelper.GetCouponSurplus(couponItemInfo.CouponId);

            if (couponSurplus <= 0)
            {
                return(CouponActionStatus.InadequateInventory);
            }
            int couponObtainNum = CouponHelper.GetCouponObtainNum(couponItemInfo.CouponId, couponItemInfo.UserId.Value);

            if (couponObtainNum >= eFCoupon.UserLimitCount && eFCoupon.UserLimitCount > 0)
            {
                return(CouponActionStatus.CannotReceive);
            }
            if (string.IsNullOrEmpty(couponItemInfo.ClaimCode))
            {
                couponItemInfo.ClaimCode = Guid.NewGuid().ToString();
            }
            return(CouponHelper.AddCouponItem(couponItemInfo));
        }
        public static CouponActionStatus AddCouponItemInfo(MemberInfo user, int couponId)
        {
            CouponInfo eFCoupon = CouponHelper.GetEFCoupon(couponId);

            if (eFCoupon == null)
            {
                return(CouponActionStatus.NotExists);
            }
            if (user == null)
            {
                return(CouponActionStatus.InconsistentInformationUser);
            }
            if (eFCoupon.ClosingTime < DateTime.Now)
            {
                return(CouponActionStatus.Overdue);
            }
            int couponSurplus = CouponHelper.GetCouponSurplus(couponId);

            if (couponSurplus <= 0)
            {
                return(CouponActionStatus.InadequateInventory);
            }
            int couponObtainNum = CouponHelper.GetCouponObtainNum(couponId, user.UserId);

            if (couponObtainNum >= eFCoupon.UserLimitCount && eFCoupon.UserLimitCount > 0)
            {
                return(CouponActionStatus.CannotReceive);
            }
            if (eFCoupon.ObtainWay == 2)
            {
                int             points          = user.Points;
                PointDetailInfo pointDetailInfo = new PointDetailInfo();
                pointDetailInfo.OrderId   = string.Empty;
                pointDetailInfo.UserId    = user.UserId;
                pointDetailInfo.TradeDate = DateTime.Now;
                pointDetailInfo.TradeType = PointTradeType.ChangeCoupon;
                pointDetailInfo.Increased = 0;
                pointDetailInfo.Reduced   = eFCoupon.NeedPoint;
                pointDetailInfo.Points    = points - eFCoupon.NeedPoint;
                if (pointDetailInfo.Points < 0)
                {
                    return(CouponActionStatus.PointNotEnough);
                }
                if (new PointDetailDao().Add(pointDetailInfo, null) <= 0)
                {
                    return(CouponActionStatus.UnknowError);
                }
                user.Points = pointDetailInfo.Points;
            }
            CouponItemInfo couponItemInfo = new CouponItemInfo();

            couponItemInfo.UserId             = user.UserId;
            couponItemInfo.UserName           = user.UserName;
            couponItemInfo.CanUseProducts     = eFCoupon.CanUseProducts;
            couponItemInfo.CouponId           = eFCoupon.CouponId;
            couponItemInfo.CouponName         = eFCoupon.CouponName;
            couponItemInfo.OrderUseLimit      = eFCoupon.OrderUseLimit;
            couponItemInfo.Price              = eFCoupon.Price;
            couponItemInfo.StartTime          = eFCoupon.StartTime;
            couponItemInfo.ClosingTime        = eFCoupon.ClosingTime;
            couponItemInfo.UseWithGroup       = eFCoupon.UseWithGroup;
            couponItemInfo.UseWithPanicBuying = eFCoupon.UseWithPanicBuying;
            couponItemInfo.UseWithFireGroup   = eFCoupon.UseWithFireGroup;
            couponItemInfo.ClaimCode          = Guid.NewGuid().ToString();
            couponItemInfo.GetDate            = DateTime.Now;
            return(CouponHelper.AddCouponItem(couponItemInfo));
        }