예제 #1
0
        private void SendSendCouponToUsers(int couponId)
        {
            MemberInfo user = HiContext.Current.User;

            if (HiContext.Current.User != null && !HiContext.Current.User.IsSubscribe)
            {
                this.litPrompt.Text  = "您尚未关注公众号!";
                this.buy.NavigateUrl = "Default.aspx";
                this.buy.Text        = "返回商城首页";
            }
            else
            {
                CouponActionStatus couponActionStatus = CouponHelper.AddCouponItemInfo(user, couponId);
                if (couponActionStatus == CouponActionStatus.Success)
                {
                    this.litPrompt.Text  = "优惠券领取成功!";
                    this.buy.NavigateUrl = "Default.aspx";
                }
                else
                {
                    this.litPrompt.Text = "优惠券领取失败!";
                    if (couponActionStatus == CouponActionStatus.InadequateInventory)
                    {
                        this.litPrompt.Text = "抱歉,优惠券已领完!";
                    }
                    if (couponActionStatus == CouponActionStatus.CannotReceive)
                    {
                        this.litPrompt.Text = "您已领过该优惠券!";
                    }
                    this.buy.NavigateUrl = "Default.aspx";
                    this.buy.Text        = "返回商城";
                }
            }
        }
예제 #2
0
        public CouponActionStatus CreateCoupon(CouponInfo coupon, int count, out string lotNumber)
        {
            CouponActionStatus unknowError = CouponActionStatus.UnknowError;

            lotNumber = string.Empty;
            if (count <= 0)
            {
                lotNumber = string.Empty;
                if (null == coupon)
                {
                    return(CouponActionStatus.UnknowError);
                }
                DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT CouponId  FROM Hishop_Coupons WHERE Name=@Name");
                this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
                if (Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) >= 1)
                {
                    return(CouponActionStatus.DuplicateName);
                }
                sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_Coupons ([Name],  ClosingTime,StartTime, Description, Amount, DiscountValue,SentCount,UsedCount,NeedPoint) VALUES(@Name, @ClosingTime,@StartTime, @Description, @Amount, @DiscountValue,0,0,@NeedPoint); SELECT @@IDENTITY");
                this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
                this.database.AddInParameter(sqlStringCommand, "ClosingTime", DbType.DateTime, coupon.ClosingTime);
                this.database.AddInParameter(sqlStringCommand, "StartTime", DbType.DateTime, coupon.StartTime);
                this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, coupon.Description);
                this.database.AddInParameter(sqlStringCommand, "DiscountValue", DbType.Currency, coupon.DiscountValue);
                this.database.AddInParameter(sqlStringCommand, "NeedPoint", DbType.Int32, coupon.NeedPoint);
                if (coupon.Amount.HasValue)
                {
                    this.database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, coupon.Amount.Value);
                }
                else
                {
                    this.database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, DBNull.Value);
                }
                object obj2 = this.database.ExecuteScalar(sqlStringCommand);
                if ((obj2 != null) && (obj2 != DBNull.Value))
                {
                    unknowError = CouponActionStatus.CreateClaimCodeSuccess;
                }
                return(unknowError);
            }
            unknowError = CouponActionStatus.CreateClaimCodeSuccess;
            DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_ClaimCode_Create");

            this.database.AddInParameter(storedProcCommand, "CouponId", DbType.Int32, coupon.CouponId);
            this.database.AddInParameter(storedProcCommand, "row", DbType.Int32, count);
            this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, null);
            this.database.AddInParameter(storedProcCommand, "UserName", DbType.String, null);
            this.database.AddInParameter(storedProcCommand, "EmailAddress", DbType.String, null);
            this.database.AddOutParameter(storedProcCommand, "ReturnLotNumber", DbType.String, 300);
            try
            {
                this.database.ExecuteNonQuery(storedProcCommand);
                lotNumber = (string)this.database.GetParameterValue(storedProcCommand, "ReturnLotNumber");
            }
            catch
            {
                unknowError = CouponActionStatus.CreateClaimCodeError;
            }
            return(unknowError);
        }
예제 #3
0
        private void btnEditCoupons_Click(object sender, EventArgs e)
        {
            decimal num;
            decimal?nullable;
            int     num2;

            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else if (!this.calendarEndDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择结束日期!", false);
                }
                else if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                {
                    this.ShowMsg("开始日期不能晚于结束日期!", false);
                }
                else
                {
                    string     msg    = string.Empty;
                    CouponInfo target = new CouponInfo {
                        CouponId      = this.couponId,
                        Name          = this.txtCouponName.Text,
                        ClosingTime   = this.calendarEndDate.SelectedDate.Value,
                        StartTime     = this.calendarStartDate.SelectedDate.Value,
                        Amount        = nullable,
                        DiscountValue = num,
                        NeedPoint     = num2
                    };
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <CouponInfo>(target, new string[] { "ValCoupon" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                            this.ShowMsg(msg, false);
                            return;
                        }
                    }
                    CouponActionStatus status = CouponHelper.UpdateCoupon(target);
                    if (status == CouponActionStatus.Success)
                    {
                        this.RestCoupon();
                        this.ShowMsg("成功修改了优惠券信息", true);
                    }
                    else if (status == CouponActionStatus.DuplicateName)
                    {
                        this.ShowMsg("修改优惠券信息错误,已经具有此优惠券名称", false);
                    }
                    else
                    {
                        this.ShowMsg("未知错误", false);
                        this.RestCoupon();
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }
예제 #5
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");
            }
        }
예제 #6
0
        protected void btnEditCoupons_Click(object sender, EventArgs e)
        {
            decimal num;
            decimal?nullable;
            int     num2;

            if (ValidateValues(out nullable, out num, out num2))
            {
                if (!calendarEndDate.SelectedDate.HasValue)
                {
                    ShowMsg("请选择结束日期!", false);
                }
                else
                {
                    string     msg    = string.Empty;
                    CouponInfo target = new CouponInfo();
                    target.CouponId      = couponId;
                    target.Name          = txtCouponName.Text;
                    target.ClosingTime   = calendarEndDate.SelectedDate.Value;
                    target.Amount        = nullable;
                    target.DiscountValue = num;
                    target.NeedPoint     = num2;
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <CouponInfo>(target, new string[] { "ValCoupon" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                            ShowMsg(msg, false);
                            return;
                        }
                    }
                    CouponActionStatus status = SubsiteCouponHelper.UpdateCoupon(target);
                    if (status == CouponActionStatus.Success)
                    {
                        RestCoupon();
                        ShowMsg("成功修改了优惠券信息", true);
                    }
                    else if (status == CouponActionStatus.DuplicateName)
                    {
                        ShowMsg("修改优惠券信息错误,已经具有此优惠券名称", false);
                    }
                    else
                    {
                        ShowMsg("未知错误", false);
                        RestCoupon();
                    }
                }
            }
        }
예제 #7
0
        public void AddCouponItemInfo(OAuthUserInfo oAuthUserInfo, RedEnvelopeGetRecordInfo redEnvelopeGetRecord)
        {
            CouponItemInfo couponItemInfo = new CouponItemInfo();
            MemberInfo     memberInfo     = null;

            memberInfo = ((HiContext.Current.UserId <= 0) ? MemberProcessor.GetMemberByOpenId("hishop.plugins.openid.weixin", oAuthUserInfo.OpenId) : HiContext.Current.User);
            if (memberInfo == null)
            {
                IDictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("OpenId", oAuthUserInfo.OpenId);
                dictionary.Add("IsAttention", oAuthUserInfo.IsAttention.ToNullString());
                dictionary.Add("unionId", oAuthUserInfo.unionId);
                dictionary.Add("NickName", oAuthUserInfo.NickName);
                dictionary.Add("ErrMsg", oAuthUserInfo.ErrMsg);
                dictionary.Add("RedEnvelopeId", redEnvelopeGetRecord.RedEnvelopeId.ToNullString());
                dictionary.Add("UserName", redEnvelopeGetRecord.UserName.ToNullString());
                dictionary.Add("OrderId", redEnvelopeGetRecord.OrderId.ToNullString());
                dictionary.Add("RedOpenId", redEnvelopeGetRecord.OpenId.ToNullString());
                dictionary.Add("SendCode", redEnvelopeGetRecord.SendCode.ToNullString());
                Globals.AppendLog(dictionary, "", "", "", "AddCouponItemInfo");
                this.toLogin.Visible    = true;
                this.toBuy.Visible      = false;
                this.divGetList.Visible = false;
            }
            else
            {
                couponItemInfo.UserId             = memberInfo.UserId;
                couponItemInfo.UserName           = redEnvelopeGetRecord.UserName;
                couponItemInfo.CanUseProducts     = "";
                couponItemInfo.ClosingTime        = this.weiXinRedEnvelope.EffectivePeriodEndTime;
                couponItemInfo.CouponId           = 0;
                couponItemInfo.RedEnvelopeId      = this.weiXinRedEnvelope.Id;
                couponItemInfo.CouponName         = this.weiXinRedEnvelope.Name;
                couponItemInfo.OrderUseLimit      = this.weiXinRedEnvelope.EnableUseMinAmount;
                couponItemInfo.Price              = redEnvelopeGetRecord.Amount;
                couponItemInfo.StartTime          = this.weiXinRedEnvelope.EffectivePeriodStartTime;
                couponItemInfo.UseWithGroup       = false;
                couponItemInfo.UseWithPanicBuying = false;
                couponItemInfo.UseWithFireGroup   = false;
                couponItemInfo.GetDate            = DateTime.Now;
                if (WeiXinRedEnvelopeProcessor.SetRedEnvelopeGetRecordToMember(redEnvelopeGetRecord.Id, memberInfo.UserName))
                {
                    CouponActionStatus couponActionStatus = CouponHelper.AddRedEnvelopeItemInfo(couponItemInfo);
                }
            }
        }
예제 #8
0
        public CouponActionStatus CreateCoupon(CouponInfo coupon)
        {
            CouponActionStatus couponActionStatus = CouponActionStatus.UnknowError;
            CouponActionStatus result;

            try
            {
                System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT CouponId  FROM Hishop_Coupon_Coupons WHERE CouponName=@CouponName and Finished=0");
                this.database.AddInParameter(sqlStringCommand, "CouponName", System.Data.DbType.String, coupon.CouponName);
                if (Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) >= 1)
                {
                    couponActionStatus = CouponActionStatus.DuplicateName;
                    result             = couponActionStatus;
                    return(result);
                }
                sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO [Hishop_Coupon_Coupons] ([CouponName],[CouponValue],[ConditionValue],[BeginDate],[EndDate],[StockNum],[ReceiveNum],[UsedNum],[MemberGrades],[DefualtGroup],[CustomGroup],[ImgUrl],[ProductNumber],[Finished],[IsAllProduct],maxReceivNum,CouponTypes) VALUES (@CouponName,@CouponValue,@ConditionValue,@BeginDate,@EndDate,@StockNum,@ReceiveNum,@UsedNum,@MemberGrades,@DefualtGroup,@CustomGroup,@ImgUrl,@ProductNumber,@Finished,@IsAllProduct,@maxReceivNum,@CouponTypes)");
                this.database.AddInParameter(sqlStringCommand, "CouponName", System.Data.DbType.String, coupon.CouponName);
                this.database.AddInParameter(sqlStringCommand, "CouponValue", System.Data.DbType.Decimal, coupon.CouponValue);
                this.database.AddInParameter(sqlStringCommand, "ConditionValue", System.Data.DbType.Decimal, coupon.ConditionValue);
                this.database.AddInParameter(sqlStringCommand, "BeginDate", System.Data.DbType.DateTime, coupon.BeginDate);
                this.database.AddInParameter(sqlStringCommand, "EndDate", System.Data.DbType.DateTime, coupon.EndDate);
                this.database.AddInParameter(sqlStringCommand, "StockNum", System.Data.DbType.Int32, coupon.StockNum);
                this.database.AddInParameter(sqlStringCommand, "ReceiveNum", System.Data.DbType.Int32, coupon.ReceiveNum);
                this.database.AddInParameter(sqlStringCommand, "UsedNum", System.Data.DbType.Int32, coupon.UsedNum);
                this.database.AddInParameter(sqlStringCommand, "MemberGrades", System.Data.DbType.String, coupon.MemberGrades);
                this.database.AddInParameter(sqlStringCommand, "DefualtGroup", System.Data.DbType.String, coupon.DefualtGroup);
                this.database.AddInParameter(sqlStringCommand, "CustomGroup", System.Data.DbType.String, coupon.CustomGroup);
                this.database.AddInParameter(sqlStringCommand, "ImgUrl", System.Data.DbType.String, coupon.ImgUrl);
                this.database.AddInParameter(sqlStringCommand, "ProductNumber", System.Data.DbType.Int32, coupon.ProductNumber);
                this.database.AddInParameter(sqlStringCommand, "Finished", System.Data.DbType.Boolean, coupon.Finished);
                this.database.AddInParameter(sqlStringCommand, "IsAllProduct", System.Data.DbType.Boolean, coupon.IsAllProduct);
                this.database.AddInParameter(sqlStringCommand, "maxReceivNum", System.Data.DbType.Int32, coupon.maxReceivNum);
                this.database.AddInParameter(sqlStringCommand, "CouponTypes", System.Data.DbType.String, coupon.CouponTypes);
                object obj = this.database.ExecuteScalar(sqlStringCommand);
                couponActionStatus = CouponActionStatus.Success;
            }
            catch (Exception var_3_263)
            {
                couponActionStatus = CouponActionStatus.CreateClaimCodeError;
            }
            result = couponActionStatus;
            return(result);
        }
예제 #9
0
        public CouponActionStatus ExportCoupon(CouponInfo coupon, int count, out string lotNumber)
        {
            CouponActionStatus result = CouponActionStatus.UnknowError;
            Guid guid = Guid.NewGuid();

            lotNumber = guid.ToString().ToUpper();
            StringBuilder stringBuilder = new StringBuilder();

            try
            {
                result = CouponActionStatus.CreateClaimCodeSuccess;
                for (int i = 0; i < count; i++)
                {
                    stringBuilder.Append("INSERT Hishop_CouponItems (CouponId,\r\n                                 LotNumber,\r\n                                 ClaimCode,\r\n                                 UserId,\r\n                                 UserName,\r\n                                 EmailAddress,\r\n                                 GenerateTime,\r\n                                 CouponStatus,\r\n                                 UsedTime,\r\n                                 OrderId) values(@CouponId,@LotNumber,@ClaimCode" + i + ",null,null,null,@GenerateTime,0,null,null);");
                }
                DbCommand sqlStringCommand = base.database.GetSqlStringCommand(stringBuilder.ToString());
                base.database.AddInParameter(sqlStringCommand, "LotNumber", DbType.String, lotNumber);
                base.database.AddInParameter(sqlStringCommand, "CouponId", DbType.Int32, coupon.CouponId);
                for (int j = 0; j < count; j++)
                {
                    Database  database = base.database;
                    DbCommand command  = sqlStringCommand;
                    string    name     = "ClaimCode" + j;
                    guid = Guid.NewGuid();
                    database.AddInParameter(command, name, DbType.String, guid.ToString().ToUpper().Replace("-", "")
                                            .Substring(0, 15));
                }
                base.database.AddInParameter(sqlStringCommand, "GenerateTime", DbType.DateTime, DateTime.Now);
                try
                {
                    base.database.ExecuteNonQuery(sqlStringCommand);
                }
                catch
                {
                    result = CouponActionStatus.CreateClaimCodeError;
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
예제 #10
0
        public static CouponActionStatus UpdateCoupon2(CouponInfo coupon)
        {
            CouponDao          couponDao = new CouponDao();
            CouponActionStatus result    = CouponActionStatus.UnknowError;

            try
            {
                if (couponDao.ExiCouponName(coupon.CouponId, coupon.CouponName))
                {
                    result = CouponActionStatus.DuplicateName;
                }
                else if (couponDao.Update(coupon, null))
                {
                    result = CouponActionStatus.Success;
                }
            }
            catch (Exception)
            {
            }
            return(result);
        }
예제 #11
0
        private void btnAddCoupons_Click(object sender, EventArgs e)
        {
            decimal num;
            decimal?nullable;
            int     num2;
            string  msg = string.Empty;

            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else if (!this.calendarEndDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择结束日期!", false);
                }
                else if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                {
                    this.ShowMsg("开始日期不能晚于结束日期!", false);
                }
                else
                {
                    CouponInfo target = new CouponInfo {
                        Name          = this.txtCouponName.Text,
                        ClosingTime   = this.calendarEndDate.SelectedDate.Value,
                        StartTime     = this.calendarStartDate.SelectedDate.Value,
                        Amount        = nullable,
                        DiscountValue = num,
                        NeedPoint     = num2
                    };
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <CouponInfo>(target, new string[] { "ValCoupon" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                            this.ShowMsg(msg, false);
                            return;
                        }
                    }
                    string             lotNumber = string.Empty;
                    CouponActionStatus status    = CouponHelper.CreateCoupon(target, 0, out lotNumber);
                    if (status != CouponActionStatus.UnknowError)
                    {
                        switch (status)
                        {
                        case CouponActionStatus.DuplicateName:
                            this.ShowMsg("已经存在相同的优惠券名称", false);
                            return;

                        case CouponActionStatus.CreateClaimCodeError:
                            this.ShowMsg("生成优惠券号码错误", false);
                            return;
                        }
                        this.ShowMsg("添加优惠券成功", true);
                        this.RestCoupon();
                    }
                    else
                    {
                        this.ShowMsg("未知错误", false);
                    }
                }
            }
        }
예제 #12
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     try
     {
         string   str        = context.Request["name"].ToString();
         string   val        = context.Request["val"].ToString();
         string   str3       = context.Request["condition"].ToString();
         string   str4       = context.Request["begin"].ToString();
         string   str5       = context.Request["end"].ToString();
         string   str6       = context.Request["total"].ToString();
         string   str7       = context.Request["isAllMember"].ToString();
         string   str8       = context.Request["memberlvl"].ToString();
         string   str9       = context.Request["maxNum"].ToString();
         string   str10      = context.Request["type"].ToString();
         string   couponName = "";
         decimal  i          = 0M;
         decimal  num2       = 0M;
         DateTime now        = DateTime.Now;
         DateTime time2      = DateTime.Now;
         int      num3       = 0;
         bool     flag       = false;
         string   str12      = "";
         int      num4       = 1;
         int      num5       = 0;
         if (string.IsNullOrEmpty(str) || (str.Length > 20))
         {
             context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券名称\"}");
         }
         else
         {
             couponName = str;
             if (!this.bDecimal(val, ref i))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券面值\"}");
             }
             else if (!this.bDecimal(str3, ref num2))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券适用最大满足额\"}");
             }
             else if (!this.bDate(str4, true, ref now))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的生效日期\"}");
             }
             else if (!this.bDate(str5, false, ref time2))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的失效日期\"}");
             }
             else if (!this.bInt(str6, ref num3))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券发放量\"}");
             }
             else
             {
                 flag = bool.Parse(str7);
                 if (!flag)
                 {
                     if (string.IsNullOrEmpty(str8))
                     {
                         context.Response.Write("{\"type\":\"error\",\"data\":\"请选择正确的会员等级\"}");
                         return;
                     }
                     str12 = str8;
                 }
                 if (!this.bInt(str9, ref num4))
                 {
                     context.Response.Write("{\"type\":\"error\",\"data\":\"请选择正确的优惠券最大领取张数\"}");
                 }
                 else
                 {
                     this.bInt(str10, ref num5);
                     if ((num2 < i) && (num2 != 0M))
                     {
                         context.Response.Write("{\"type\":\"error\",\"data\":\"优惠券面值不能大于满足金额\"}");
                     }
                     else if (time2 < now)
                     {
                         context.Response.Write("{\"type\":\"error\",\"data\":\"优惠券失效日期不能早于生效日期\"}");
                     }
                     else
                     {
                         CouponInfo coupon = new CouponInfo {
                             CouponName     = couponName,
                             CouponValue    = i,
                             ConditionValue = num2,
                             BeginDate      = now,
                             EndDate        = time2,
                             StockNum       = num3,
                             IsAllProduct   = (num5 == 0) ? true : false
                         };
                         if (flag)
                         {
                             coupon.MemberGrades = "0";
                         }
                         else
                         {
                             coupon.MemberGrades = str12;
                         }
                         coupon.maxReceivNum = num4;
                         CouponActionStatus status = CouponHelper.CreateCoupon(coupon);
                         if (status == CouponActionStatus.Success)
                         {
                             coupon = CouponHelper.GetCoupon(couponName);
                             if (coupon != null)
                             {
                                 context.Response.Write("{\"type\":\"success\",\"data\":\"" + coupon.CouponId.ToString() + "\"}");
                             }
                             else
                             {
                                 context.Response.Write("{\"type\":\"error\",\"data\":\"写数据库异常\"}");
                             }
                         }
                         else
                         {
                             context.Response.Write("{\"type\":\"error\",\"data\":\"" + this.GetErrMsg(status.ToString()) + "\"}");
                         }
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         context.Response.Write("{\"type\":\"error\",\"data\":\"" + exception.Message + "\"}");
     }
 }
예제 #13
0
        protected void btnExport_Click(object sender, System.EventArgs e)
        {
            int num;

            if (!int.TryParse(this.tbcouponNum.Text, out num))
            {
                this.ShowMsg("导出数量必须为正数", false);
                return;
            }
            if (num <= 0)
            {
                this.ShowMsg("导出数量必须为正数", false);
                return;
            }
            int couponId;

            if (!int.TryParse(this.txtcouponid.Value, out couponId))
            {
                this.ShowMsg("参数错误", false);
                return;
            }
            CouponInfo         coupon             = CouponHelper.GetCoupon(couponId);
            string             empty              = string.Empty;
            CouponActionStatus couponActionStatus = CouponHelper.CreateCoupon(coupon, num, out empty);

            if (couponActionStatus == CouponActionStatus.UnknowError)
            {
                this.ShowMsg("未知错误", false);
                return;
            }
            if (couponActionStatus == CouponActionStatus.CreateClaimCodeError)
            {
                this.ShowMsg("生成优惠券号码错误", false);
                return;
            }
            if (couponActionStatus == CouponActionStatus.CreateClaimCodeSuccess && !string.IsNullOrEmpty(empty))
            {
                System.Collections.Generic.IList <CouponItemInfo> couponItemInfos = CouponHelper.GetCouponItemInfos(empty);
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">");
                stringBuilder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">");
                stringBuilder.AppendLine("<td>优惠券批次号</td>");
                stringBuilder.AppendLine("<td>优惠券号码</td>");
                stringBuilder.AppendLine("<td>优惠券金额</td>");
                stringBuilder.AppendLine("<td>过期时间</td>");
                stringBuilder.AppendLine("</tr>");
                foreach (CouponItemInfo current in couponItemInfos)
                {
                    stringBuilder.AppendLine("<tr>");
                    stringBuilder.AppendLine("<td>" + empty + "</td>");
                    stringBuilder.AppendLine("<td>" + current.ClaimCode + "</td>");
                    stringBuilder.AppendLine("<td>" + coupon.DiscountValue + "</td>");
                    stringBuilder.AppendLine("<td>" + coupon.ClosingTime + "</td>");
                    stringBuilder.AppendLine("</tr>");
                }
                stringBuilder.AppendLine("</table>");
                this.Page.Response.Clear();
                this.Page.Response.Buffer  = false;
                this.Page.Response.Charset = "GB2312";
                this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=CouponsInfo_" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
                this.Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                this.Page.Response.ContentType     = "application/ms-excel";
                this.Page.EnableViewState          = false;
                this.Page.Response.Write(stringBuilder.ToString());
                this.Page.Response.End();
            }
        }
예제 #14
0
 public void ProcessRequest(System.Web.HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     try
     {
         string          text         = context.Request["name"].ToString().Trim();
         string          val          = context.Request["val"].ToString().Trim();
         string          val2         = context.Request["condition"].ToString().Trim();
         string          val3         = context.Request["begin"].ToString().Trim();
         string          val4         = context.Request["end"].ToString().Trim();
         string          val5         = context.Request["total"].ToString().Trim();
         string          value        = context.Request["isAllMember"].ToString().Trim();
         string          text2        = context.Request["memberlvl"].ToString().Trim();
         string          text3        = context.Request["defualtGroup"].ToString().Trim();
         string          text4        = context.Request["customGroup"].ToString().Trim();
         string          val6         = context.Request["maxNum"].ToString().Trim();
         string          val7         = context.Request["type"].ToString().Trim();
         string          couponTypes  = context.Request["couponType"].ToString().Trim();
         decimal         num          = 0m;
         decimal         num2         = 0m;
         System.DateTime now          = System.DateTime.Now;
         System.DateTime now2         = System.DateTime.Now;
         int             stockNum     = 0;
         string          memberGrades = "";
         int             maxReceivNum = 1;
         int             num3         = 0;
         if (string.IsNullOrEmpty(text) || text.Length > 20)
         {
             context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券名称\"}");
         }
         else
         {
             string couponName = text;
             if (!this.bDecimal(val, ref num))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券面值\"}");
             }
             else if (!this.bDecimal(val2, ref num2))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券适用最大满足额\"}");
             }
             else if (!this.bDate(val3, true, ref now))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的生效日期\"}");
             }
             else if (!this.bDate(val4, false, ref now2))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的失效日期\"}");
             }
             else if (!this.bInt(val5, ref stockNum))
             {
                 context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的优惠券发放量\"}");
             }
             else
             {
                 bool flag = bool.Parse(value);
                 if (!flag)
                 {
                     if (string.IsNullOrEmpty(text2) && string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text4))
                     {
                         context.Response.Write("{\"type\":\"error\",\"data\":\"请选择正确的会员等级\"}");
                         return;
                     }
                     memberGrades = text2;
                 }
                 if (!this.bInt(val6, ref maxReceivNum))
                 {
                     context.Response.Write("{\"type\":\"error\",\"data\":\"请选择正确的优惠券最大领取张数\"}");
                 }
                 else
                 {
                     this.bInt(val7, ref num3);
                     if (num2 < num && num2 != 0m)
                     {
                         context.Response.Write("{\"type\":\"error\",\"data\":\"优惠券面值不能大于满足金额\"}");
                     }
                     else if (now2 < now)
                     {
                         context.Response.Write("{\"type\":\"error\",\"data\":\"优惠券失效日期不能早于生效日期\"}");
                     }
                     else
                     {
                         CouponInfo couponInfo = new CouponInfo();
                         couponInfo.CouponName     = couponName;
                         couponInfo.CouponValue    = num;
                         couponInfo.ConditionValue = num2;
                         couponInfo.BeginDate      = now;
                         couponInfo.EndDate        = now2;
                         couponInfo.StockNum       = stockNum;
                         couponInfo.IsAllProduct   = (num3 == 0);
                         if (flag)
                         {
                             couponInfo.MemberGrades = "0";
                             couponInfo.DefualtGroup = "0";
                             couponInfo.CustomGroup  = "0";
                         }
                         else
                         {
                             couponInfo.MemberGrades = memberGrades;
                             couponInfo.DefualtGroup = text3;
                             couponInfo.CustomGroup  = text4;
                         }
                         couponInfo.maxReceivNum = maxReceivNum;
                         couponInfo.CouponTypes  = couponTypes;
                         CouponActionStatus couponActionStatus = CouponHelper.CreateCoupon(couponInfo);
                         if (couponActionStatus == CouponActionStatus.Success)
                         {
                             couponInfo = CouponHelper.GetCoupon(couponName);
                             if (couponInfo != null)
                             {
                                 context.Response.Write("{\"type\":\"success\",\"data\":\"" + couponInfo.CouponId.ToString() + "\"}");
                             }
                             else
                             {
                                 context.Response.Write("{\"type\":\"error\",\"data\":\"写数据库异常\"}");
                             }
                         }
                         else
                         {
                             context.Response.Write("{\"type\":\"error\",\"data\":\"" + this.GetErrMsg(couponActionStatus.ToString()) + "\"}");
                         }
                     }
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         context.Response.Write("{\"type\":\"error\",\"data\":\"" + ex.Message + "\"}");
     }
 }
예제 #15
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            string text  = base.Request.Form["CheckBoxGroup"].ToNullString();
            string text2 = this.Page.Request["UserIds"].ToNullString();

            if (string.IsNullOrEmpty(text))
            {
                this.ShowMsg("请选择赠送的优惠券", false);
            }
            else
            {
                List <CouponInfo> list  = new List <CouponInfo>();
                string[]          array = text.Split(',');
                foreach (string text3 in array)
                {
                    if (!string.IsNullOrEmpty(text3))
                    {
                        int num = 0;
                        if (int.TryParse(text3, out num) && num > 0)
                        {
                            CouponInfo eFCoupon = CouponHelper.GetEFCoupon(num);
                            if (eFCoupon != null)
                            {
                                list.Add(eFCoupon);
                            }
                        }
                    }
                }
                if (list.Count == 0)
                {
                    this.btnSure.Text    = "确 定";
                    this.btnSure.Enabled = true;
                    this.ShowMsg("请选择赠送的优惠券", false);
                }
                else
                {
                    string   empty  = string.Empty;
                    int      num2   = 0;
                    int      num3   = 0;
                    int      num4   = 0;
                    string[] array2 = text2.Split(',');
                    foreach (string s in array2)
                    {
                        int num5 = 0;
                        if (int.TryParse(s, out num5) && num5 > 0)
                        {
                            MemberInfo user = Users.GetUser(num5);
                            num4 = 0;
                            decimal num6 = default(decimal);
                            foreach (CouponInfo item in list)
                            {
                                CouponItemInfo couponItemInfo = new CouponItemInfo();
                                couponItemInfo.UserId             = user.UserId;
                                couponItemInfo.UserName           = user.UserName;
                                couponItemInfo.CanUseProducts     = item.CanUseProducts;
                                couponItemInfo.ClosingTime        = item.ClosingTime;
                                couponItemInfo.CouponId           = item.CouponId;
                                couponItemInfo.CouponName         = item.CouponName;
                                couponItemInfo.OrderUseLimit      = item.OrderUseLimit;
                                couponItemInfo.Price              = item.Price;
                                couponItemInfo.StartTime          = item.StartTime;
                                couponItemInfo.UseWithGroup       = item.UseWithGroup;
                                couponItemInfo.UseWithPanicBuying = item.UseWithPanicBuying;
                                couponItemInfo.UseWithFireGroup   = item.UseWithFireGroup;
                                couponItemInfo.GetDate            = DateTime.Now;
                                CouponActionStatus couponActionStatus = CouponHelper.AddCouponItemInfo(couponItemInfo);
                                num6 += item.Price;
                                if (couponActionStatus == CouponActionStatus.Success)
                                {
                                    num2++;
                                    num4++;
                                }
                                else
                                {
                                    num3++;
                                }
                            }
                            if (num4 > 0)
                            {
                                Messenger.GiftCoupons(user, num4, num6);
                            }
                        }
                    }
                    if (num2 + num3 > 0)
                    {
                        base.CloseWindow("成功发送" + num2 + "张优惠券," + num3 + "张优惠券发送失败");
                    }
                    else
                    {
                        this.ShowMsg("成功失败", false);
                    }
                }
            }
        }
예제 #16
0
파일: AddCoupon.cs 프로젝트: tyriankid/WFX
        private void btnAddCoupons_Click(object sender, System.EventArgs e)
        {
            string  msg = string.Empty;
            decimal?nullable;
            decimal num;
            int     num2;

            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else
                {
                    if (!this.calendarEndDate.SelectedDate.HasValue)
                    {
                        this.ShowMsg("请选择结束日期!", false);
                    }
                    else
                    {
                        if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                        {
                            this.ShowMsg("开始日期不能晚于结束日期!", false);
                        }
                        else
                        {
                            CouponInfo target = new CouponInfo
                            {
                                Name          = this.txtCouponName.Text,
                                ClosingTime   = this.calendarEndDate.SelectedDate.Value,
                                StartTime     = this.calendarStartDate.SelectedDate.Value,
                                Amount        = nullable,
                                DiscountValue = num,
                                NeedPoint     = num2
                            };
                            ValidationResults results = Validation.Validate <CouponInfo>(target, new string[]
                            {
                                "ValCoupon"
                            });
                            if (!results.IsValid)
                            {
                                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)results).GetEnumerator())
                                {
                                    if (enumerator.MoveNext())
                                    {
                                        ValidationResult result = enumerator.Current;
                                        msg += Formatter.FormatErrorMessage(result.Message);
                                        this.ShowMsg(msg, false);
                                        return;
                                    }
                                }
                            }
                            string             lotNumber = string.Empty;
                            CouponActionStatus status    = CouponHelper.CreateCoupon(target, 0, out lotNumber);
                            if (status != CouponActionStatus.UnknowError)
                            {
                                CouponActionStatus couponActionStatus = status;
                                if (couponActionStatus != CouponActionStatus.DuplicateName)
                                {
                                    if (couponActionStatus != CouponActionStatus.CreateClaimCodeError)
                                    {
                                        this.ShowMsg("添加优惠券成功", true);
                                        this.RestCoupon();
                                    }
                                    else
                                    {
                                        this.ShowMsg("生成优惠券号码错误", false);
                                    }
                                }
                                else
                                {
                                    this.ShowMsg("已经存在相同的优惠券名称", false);
                                }
                            }
                            else
                            {
                                this.ShowMsg("未知错误", false);
                            }
                        }
                    }
                }
            }
        }
예제 #17
0
        private void btnEditCoupons_Click(object sender, System.EventArgs e)
        {
            decimal?nullable;
            decimal num;
            int     num2;

            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else
                {
                    if (!this.calendarEndDate.SelectedDate.HasValue)
                    {
                        this.ShowMsg("请选择结束日期!", false);
                    }
                    else
                    {
                        if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                        {
                            this.ShowMsg("开始日期不能晚于结束日期!", false);
                        }
                        else
                        {
                            string     msg    = string.Empty;
                            CouponInfo target = new CouponInfo();
                            if (CustomConfigHelper.Instance.IsSanzuo)
                            {
                                target.CouponId    = this.couponId;
                                target.Name        = this.txtCouponName.Text;
                                target.ClosingTime = this.calendarEndDate.SelectedDate.Value;
                                target.StartTime   = this.calendarStartDate.SelectedDate.Value;
                                if (this.DDLcategory.SelectedValue != "未选择")
                                {
                                    target.CategoryId = Convert.ToInt32(this.DDLcategory.SelectedValue);
                                }
                                else
                                {
                                    target.CategoryId = 0;
                                }
                                if (this.DDLservice.SelectedValue != "未选择")
                                {
                                    target.SenderId = Convert.ToInt32(this.DDLservice.SelectedValue);
                                }
                                else
                                {
                                    target.SenderId = 0;
                                }
                                target.Amount        = nullable;
                                target.DiscountValue = num;
                                target.NeedPoint     = num2;
                            }
                            else
                            {
                                target.CouponId      = this.couponId;
                                target.Name          = this.txtCouponName.Text;
                                target.ClosingTime   = this.calendarEndDate.SelectedDate.Value;
                                target.StartTime     = this.calendarStartDate.SelectedDate.Value;
                                target.Amount        = nullable;
                                target.DiscountValue = num;
                                target.NeedPoint     = num2;
                            }
                            ValidationResults results = Validation.Validate <CouponInfo>(target, new string[]
                            {
                                "ValCoupon"
                            });
                            if (!results.IsValid)
                            {
                                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)results).GetEnumerator())
                                {
                                    if (enumerator.MoveNext())
                                    {
                                        ValidationResult result = enumerator.Current;
                                        msg += Formatter.FormatErrorMessage(result.Message);
                                        this.ShowMsg(msg, false);
                                        return;
                                    }
                                }
                            }
                            CouponActionStatus status = CouponHelper.UpdateCoupon(target);
                            if (status == CouponActionStatus.Success)
                            {
                                this.RestCoupon();
                                this.ShowMsg("成功修改了优惠券信息", true);
                            }
                            else
                            {
                                if (status == CouponActionStatus.DuplicateName)
                                {
                                    this.ShowMsg("修改优惠券信息错误,已经具有此优惠券名称", false);
                                }
                                else
                                {
                                    this.ShowMsg("未知错误", false);
                                    this.RestCoupon();
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #18
0
        private void btnAddCoupons_Click(object sender, System.EventArgs e)
        {
            string  text     = string.Empty;
            string  arg_0B_0 = string.Empty;
            decimal?amount;
            decimal discountValue;
            int     needPoint;
            int     totalq;

            if (!this.ValidateValues(out amount, out discountValue, out needPoint, out totalq))
            {
                return;
            }
            CouponInfo couponInfo = new CouponInfo();

            #region 使用方式
            int UseType = 0;
            if (this.rdoAll.Checked)
            {
                UseType = int.Parse(this.rdoAll.Value);
            }

            else if (this.rdoProduct.Checked)
            {
                UseType = int.Parse(this.rdoProduct.Value);
            }

            else if (this.rdoProductType.Checked)
            {
                UseType = int.Parse(this.rdoProductType.Value);
            }

            else if (this.rdoBrand.Checked)
            {
                UseType = int.Parse(this.rdoBrand.Value);
            }

            else if (this.rdoSupplier.Checked)
            {
                UseType = int.Parse(this.rdoSupplier.Value);
            }
            #endregion


            #region 发送方式
            int    SendType     = 0;
            string stroverMoney = string.Empty;
            if (this.rdoManually.Checked)
            {
                SendType = int.Parse(this.rdoManually.Value);
            }

            else if (this.rdoOverMoney.Checked)
            {
                SendType     = int.Parse(this.rdoOverMoney.Value);
                stroverMoney = txtOverMoney.Text.ToString();
            }

            else if (this.rdoRegist.Checked)
            {
                SendType = int.Parse(this.rdoRegist.Value);
            }

            else if (this.rdoLq.Checked)
            {
                SendType = int.Parse(this.rdoLq.Value);
            }
            else if (this.rdorefund.Checked)
            {
                SendType = int.Parse(this.rdorefund.Value);
            }
            else if (this.rdZC.Checked)
            {
                SendType = int.Parse(this.rdZC.Value);
            }

            #endregion
            if (SendType != 4)
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                    return;
                }
                if (!this.calendarEndDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择结束日期!", false);
                    return;
                }
                if (this.calendarStartDate.SelectedDate.Value.Date.CompareTo(this.calendarEndDate.SelectedDate.Value.Date) > 0)
                {
                    this.ShowMsg("开始日期不能晚于结束日期!", false);
                    return;
                }
            }
            string strOverMoney = txtOverMoney.Text;
            if (this.rdoOverMoney.Checked && !Regex.IsMatch(strOverMoney, @"^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$"))
            {
                this.ShowMsg(" 满足金额必须为正数,且最多只能有两位小数", false);
                return;
            }
            if (string.IsNullOrEmpty(base.Request.Form["selectProductsinfo"]) && this.rdoProduct.Checked)
            {
                this.ShowMsg("请选择商品", false);
                return;
            }
            if (!this.outBeginDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择发劵开始日期!", false);
                return;
            }
            if (!this.outEndDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择发劵结束日期!", false);
                return;
            }
            if (this.outBeginDate.SelectedDate.Value.Date.CompareTo(this.outEndDate.SelectedDate.Value.Date) > 0)
            {
                this.ShowMsg("发劵开始日期不能晚于发劵结束日期!", false);
                return;
            }
            if (SendType != 4)
            {
                if (this.outEndDate.SelectedDate.Value.Date.CompareTo(this.calendarEndDate.SelectedDate.Value.Date) > 0)
                {
                    this.ShowMsg("发劵结束日期不能晚于使用结束日期!", false);
                    return;
                }
            }
            string strValidity = this.txtValidity.Text;
            if (!string.IsNullOrWhiteSpace(strValidity))
            {
                if (!Regex.IsMatch(strValidity, @"^[1-9][0-9]*$"))
                {
                    this.ShowMsg(" 有效期只能是数字,必须大于O!", false);
                    return;
                }
            }
            couponInfo.Name          = this.txtCouponName.Text;
            couponInfo.ClosingTime   = (SendType == 4 ? Convert.ToDateTime("1/1/1753 12:00:00") : this.calendarEndDate.SelectedDate.Value.AddDays(1).AddSeconds(-1));
            couponInfo.StartTime     = (SendType == 4 ? Convert.ToDateTime("1/1/1753 12:00:00") : this.calendarStartDate.SelectedDate.Value);
            couponInfo.Amount        = amount;
            couponInfo.DiscountValue = discountValue;
            couponInfo.NeedPoint     = needPoint;
            couponInfo.OutBeginDate  = this.outBeginDate.SelectedDate.Value;
            couponInfo.OutEndDate    = this.outEndDate.SelectedDate.Value;
            couponInfo.TotalQ        = totalq;
            couponInfo.Remark        = this.txtRemark.Text;
            if (!string.IsNullOrEmpty(txtValidity.Text.Trim()))
            {
                couponInfo.Validity = int.Parse(this.txtValidity.Text);
            }
            if (this.rdoSDisEnable.Checked)
            {
                couponInfo.Status = int.Parse(this.rdoSDisEnable.Value);
            }
            else
            {
                couponInfo.Status = 1;
            }
            ValidationResults validationResults = Validation.Validate <CouponInfo>(couponInfo, new string[]
            {
                "ValCoupon"
            });
            if (!validationResults.IsValid)
            {
                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ValidationResult current = enumerator.Current;
                        text += Formatter.FormatErrorMessage(current.Message);
                        this.ShowMsg(text, false);
                        return;
                    }
                }
            }
            string empty = string.Empty;

            int newcouponId = 0;


            couponInfo.UseType      = UseType;
            couponInfo.SendType     = SendType;
            couponInfo.SendTypeItem = stroverMoney;

            #region 添加优惠券
            if (this.couponId == 0)
            {
                CouponActionStatus couponActionStatus = CouponHelper.CreateCoupon(couponInfo, 0, out empty, out newcouponId);


                if (couponActionStatus == CouponActionStatus.UnknowError)
                {
                    this.ShowMsg("未知错误", false);
                }
                else
                {
                    //if (couponActionStatus == CouponActionStatus.DuplicateName)
                    //{
                    //    this.ShowMsg("已经存在相同的优惠券名称", false);
                    //    return;
                    //}
                    if (couponActionStatus == CouponActionStatus.CreateClaimCodeError)
                    {
                        this.ShowMsg("生成优惠券号码错误", false);
                        return;
                    }

                    #region 插入优惠券子表
                    switch (UseType)
                    {
                    case 0: break;

                    case 1:
                        string   productselectList = base.Request.Form["selectProductsinfo"];
                        string[] array             = productselectList.Split(new char[] { ',' });
                        for (int i = 0; i < array.Length; i++)
                        {
                            //string text2 = array[i];
                            //string[] array2 = text2.Split(new char[] { '|' });
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = newcouponId;
                            senditem.BindId   = System.Convert.ToInt32(array[i]);
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    case 2:
                        string   producttypeList  = base.Request.Form["ProductTypelist"];
                        string[] arrayproducttype = producttypeList.Split(new char[] { ',' });
                        for (int i = 0; i < arrayproducttype.Length; i++)
                        {
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = newcouponId;
                            senditem.BindId   = System.Convert.ToInt32(arrayproducttype[i]);
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    case 3:
                        foreach (var item in dcBrand)
                        {
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = newcouponId;
                            senditem.BindId   = item.Key;
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    case 4:
                        foreach (var item in dcSupplier)
                        {
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = newcouponId;
                            senditem.BindId   = item.Key;
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    default: break;
                    }
                    #endregion

                    this.ShowMsg("添加优惠券成功", true);
                    this.RestCoupon();
                    return;
                }
            }

            #endregion

            #region 编辑优惠券

            else
            {
                couponInfo.CouponId = this.couponId;
                CouponActionStatus couponActionStatus = CouponHelper.NewUpdateCoupon(couponInfo);


                if (couponActionStatus == CouponActionStatus.UnknowError)
                {
                    this.ShowMsg("未知错误", false);
                }
                else
                {
                    if (couponActionStatus == CouponActionStatus.DuplicateName)
                    {
                        this.ShowMsg("已经存在相同的优惠券名称", false);
                        return;
                    }
                    if (couponActionStatus == CouponActionStatus.CreateClaimCodeError)
                    {
                        this.ShowMsg("生成优惠券号码错误", false);
                        return;
                    }

                    //删除原来的子表信息
                    CouponHelper.DeleteCouponSendTypeItem(this.couponId);
                    #region 插入优惠券子表
                    switch (UseType)
                    {
                    case 0: break;

                    case 1:
                        string   productselectList = base.Request.Form["selectProductsinfo"];
                        string[] array             = productselectList.Split(new char[] { ',' });
                        for (int i = 0; i < array.Length; i++)
                        {
                            //string text2 = array[i];
                            //string[] array2 = text2.Split(new char[] { '|' });
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = this.couponId;
                            senditem.BindId   = System.Convert.ToInt32(array[i]);
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    case 2:
                        string   producttypeList  = base.Request.Form["ProductTypelist"];
                        string[] arrayproducttype = producttypeList.Split(new char[] { ',' });
                        for (int i = 0; i < arrayproducttype.Length; i++)
                        {
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = this.couponId;
                            senditem.BindId   = System.Convert.ToInt32(arrayproducttype[i]);
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    case 3:
                        foreach (var item in dcBrand)
                        {
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = this.couponId;
                            senditem.BindId   = item.Key;
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    case 4:
                        foreach (var item in dcSupplier)
                        {
                            CouponsSendTypeItem senditem = new CouponsSendTypeItem();
                            senditem.CouponId = this.couponId;
                            senditem.BindId   = item.Key;
                            senditem.UserId   = HiContext.Current.User.UserId;
                            CouponHelper.CreateCouponsSendTypeItem(senditem);
                        }
                        break;

                    default: break;
                    }
                    #endregion

                    this.ShowMsg("编辑优惠券成功", true);
                    this.RestCoupon();
                    return;
                }
            }
            #endregion
        }
예제 #19
0
        private void btnAddCoupons_Click(object sender, System.EventArgs e)
        {
            string  msg = string.Empty;
            decimal?nullable;
            decimal num;
            int     num2;

            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else
                {
                    if (!this.calendarEndDate.SelectedDate.HasValue)
                    {
                        this.ShowMsg("请选择结束日期!", false);
                    }
                    else
                    {
                        if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                        {
                            this.ShowMsg("开始日期不能晚于结束日期!", false);
                        }
                        else
                        {
                            CouponInfo target = new CouponInfo();
                            if (CustomConfigHelper.Instance.IsSanzuo || (CustomConfigHelper.Instance.AutoShipping && CustomConfigHelper.Instance.AnonymousOrder))
                            {
                                target.Name        = this.txtCouponName.Text;
                                target.ClosingTime = this.calendarEndDate.SelectedDate.Value;
                                target.StartTime   = this.calendarStartDate.SelectedDate.Value;
                                if (this.DDLservice.SelectedValue != "未选择")
                                {
                                    target.SenderId = Convert.ToInt32(this.DDLservice.SelectedValue);
                                }
                                else
                                {
                                    target.SenderId = 0;
                                }
                                if (this.DDLcategory.SelectedValue != "未选择")
                                {
                                    target.CategoryId = Convert.ToInt32(this.DDLcategory.SelectedValue);
                                }
                                else
                                {
                                    target.CategoryId = 0;
                                }
                                target.Amount        = nullable;
                                target.DiscountValue = num;
                                target.NeedPoint     = num2;
                            }
                            else
                            {
                                target.Name          = this.txtCouponName.Text;
                                target.ClosingTime   = this.calendarEndDate.SelectedDate.Value;
                                target.StartTime     = this.calendarStartDate.SelectedDate.Value;
                                target.Amount        = nullable;
                                target.DiscountValue = num;
                                target.NeedPoint     = num2;
                            }

                            ValidationResults results = Validation.Validate <CouponInfo>(target, new string[]
                            {
                                "ValCoupon"
                            });
                            if (!results.IsValid)
                            {
                                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)results).GetEnumerator())
                                {
                                    if (enumerator.MoveNext())
                                    {
                                        ValidationResult result = enumerator.Current;
                                        msg += Formatter.FormatErrorMessage(result.Message);
                                        this.ShowMsg(msg, false);
                                        return;
                                    }
                                }
                            }


                            string lotNumber = string.Empty;
                            //创建优惠券
                            CouponActionStatus status = CouponHelper.CreateCoupon(target, 0, out lotNumber);

                            //创建微信卡包优惠券
                            //读取配置信息
                            if (false) //是否同时将生成的优惠券创建到到微信卡券内
                            {
                                Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false);
                                //CouponInfo coupon1 = CouponHelper.GetCoupon(couponId);
                                WXCouponInfo wxCoupon = new WXCouponInfo();
                                wxCoupon.card.card_type = "GENERAL_COUPON";
                                wxCoupon.card.general_coupon.base_info.code_type = "CODE_TYPE_TEXT";
                                //wxCoupon.logo_url = Globals.DomainName + masterSettings.DistributorLogoPic;
                                wxCoupon.card.general_coupon.base_info.logo_url                  = "http://yihui.ewaywin.com/Storage/data/DistributorLogoPic/20151125173959_6308.jpg";
                                wxCoupon.card.general_coupon.base_info.brand_name                = masterSettings.SiteName;
                                wxCoupon.card.general_coupon.base_info.title                     = "满" + target.Amount.ToString() + "减" + target.DiscountValue.ToString("0.00");
                                wxCoupon.card.general_coupon.base_info.sub_title                 = this.txtCouponName.Text;
                                wxCoupon.card.general_coupon.base_info.color                     = "Color100";
                                wxCoupon.card.general_coupon.base_info.notice                    = "购买商品时使用";
                                wxCoupon.card.general_coupon.base_info.description               = target.Description;
                                wxCoupon.card.general_coupon.base_info.sku.quantity              = 200;
                                wxCoupon.card.general_coupon.base_info.date_info.type            = "DATE_TYPE_FIX_TIME_RANGE";
                                wxCoupon.card.general_coupon.base_info.date_info.begin_timestamp = DateTimeToUnixTimestamp(target.StartTime);
                                wxCoupon.card.general_coupon.base_info.date_info.end_timestamp   = DateTimeToUnixTimestamp(target.ClosingTime);
                                wxCoupon.card.general_coupon.base_info.use_custom_code           = false;
                                wxCoupon.card.general_coupon.default_detail = target.Name;
                                string json         = Newtonsoft.Json.JsonConvert.SerializeObject(wxCoupon, Newtonsoft.Json.Formatting.Indented);
                                string access_token = Access_token.GetAccess_token();
                                //string access_token = "12j5h9jB21EEtpBkJKCtG3K10pZFXKAjDuM_CXJmvea6TdU_0YGCEaumhkClH0Wd3sq12901e6hqoA9VvTxemCSNUxtSoCwXSHrZ1Elb_v0CSQcAAAXNL";
                                Hidistro.UI.Web.API.wx.Post("https://api.weixin.qq.com/card/create?access_token=" + access_token, json);
                            }

                            if (status != CouponActionStatus.UnknowError)
                            {
                                CouponActionStatus couponActionStatus = status;
                                if (couponActionStatus != CouponActionStatus.DuplicateName)
                                {
                                    if (couponActionStatus != CouponActionStatus.CreateClaimCodeError)
                                    {
                                        this.ShowMsg("添加优惠券成功", true);
                                        this.RestCoupon();
                                    }
                                    else
                                    {
                                        this.ShowMsg("生成优惠券号码错误", false);
                                    }
                                }
                                else
                                {
                                    this.ShowMsg("已经存在相同的优惠券名称", false);
                                }
                            }
                            else
                            {
                                this.ShowMsg("未知错误", false);
                            }
                        }
                    }
                }
            }
        }
예제 #20
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            int num;

            if (!int.TryParse(this.tbcouponNum.Text, out num))
            {
                this.ShowMsg("导出数量必须为正数", false);
            }
            else if (num <= 0)
            {
                this.ShowMsg("导出数量必须为正数", false);
            }
            else
            {
                int num2;
                if (!int.TryParse(this.txtcouponid.Value, out num2))
                {
                    this.ShowMsg("参数错误", false);
                }
                else
                {
                    CouponInfo         coupon    = CouponHelper.GetCoupon(num2);
                    string             lotNumber = string.Empty;
                    CouponActionStatus status    = CouponHelper.CreateCoupon(coupon, num, out lotNumber);
                    switch (status)
                    {
                    case CouponActionStatus.UnknowError:
                        this.ShowMsg("未知错误", false);
                        return;

                    case CouponActionStatus.CreateClaimCodeError:
                        this.ShowMsg("生成优惠券号码错误", false);
                        return;
                    }
                    if ((status == CouponActionStatus.CreateClaimCodeSuccess) && !string.IsNullOrEmpty(lotNumber))
                    {
                        IList <CouponItemInfo> couponItemInfos = CouponHelper.GetCouponItemInfos(lotNumber);
                        StringBuilder          builder         = new StringBuilder();
                        builder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">");
                        builder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">");
                        builder.AppendLine("<td>优惠券批次号</td>");
                        builder.AppendLine("<td>优惠券号码</td>");
                        builder.AppendLine("<td>优惠券金额</td>");
                        builder.AppendLine("<td>过期时间</td>");
                        builder.AppendLine("</tr>");
                        foreach (CouponItemInfo info2 in couponItemInfos)
                        {
                            builder.AppendLine("<tr>");
                            builder.AppendLine("<td>" + lotNumber + "</td>");
                            builder.AppendLine("<td>" + info2.ClaimCode + "</td>");
                            builder.AppendLine("<td>" + coupon.DiscountValue + "</td>");
                            builder.AppendLine("<td>" + coupon.ClosingTime + "</td>");
                            builder.AppendLine("</tr>");
                        }
                        builder.AppendLine("</table>");
                        this.Page.Response.Clear();
                        this.Page.Response.Buffer  = false;
                        this.Page.Response.Charset = "GB2312";
                        this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=CouponsInfo_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
                        this.Page.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
                        this.Page.Response.ContentType     = "application/ms-excel";
                        this.Page.EnableViewState          = false;
                        this.Page.Response.Write(builder.ToString());
                        this.Page.Response.End();
                    }
                }
            }
        }
예제 #21
0
        private void btnEditCoupons_Click(object sender, System.EventArgs e)
        {
            decimal?amount;
            decimal discountValue;
            int     needPoint;

            if (!this.ValidateValues(out amount, out discountValue, out needPoint))
            {
                return;
            }
            if (!this.calendarStartDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择开始日期!", false);
                return;
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                this.ShowMsg("请选择结束日期!", false);
                return;
            }
            if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
            {
                this.ShowMsg("开始日期不能晚于结束日期!", false);
                return;
            }
            string     text       = string.Empty;
            CouponInfo couponInfo = new CouponInfo();

            couponInfo.CouponId      = this.couponId;
            couponInfo.Name          = this.txtCouponName.Text;
            couponInfo.ClosingTime   = this.calendarEndDate.SelectedDate.Value;
            couponInfo.StartTime     = this.calendarStartDate.SelectedDate.Value;
            couponInfo.Amount        = amount;
            couponInfo.DiscountValue = discountValue;
            couponInfo.NeedPoint     = needPoint;
            ValidationResults validationResults = Validation.Validate <CouponInfo>(couponInfo, new string[]
            {
                "ValCoupon"
            });

            if (!validationResults.IsValid)
            {
                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ValidationResult current = enumerator.Current;
                        text += Formatter.FormatErrorMessage(current.Message);
                        this.ShowMsg(text, false);
                        return;
                    }
                }
            }
            CouponActionStatus couponActionStatus = CouponHelper.UpdateCoupon(couponInfo);

            if (couponActionStatus == CouponActionStatus.Success)
            {
                this.RestCoupon();
                this.ShowMsg("成功修改了优惠券信息", true);
            }
            else
            {
                if (couponActionStatus == CouponActionStatus.DuplicateName)
                {
                    this.ShowMsg("修改优惠券信息错误,已经具有此优惠券名称", false);
                    return;
                }
                this.ShowMsg("未知错误", false);
                this.RestCoupon();
                return;
            }
        }
예제 #22
0
        private void btnAddCoupons_Click(object sender, EventArgs e)
        {
            decimal num;
            decimal?nullable;
            int     num2;
            int     num3;
            string  msg = string.Empty;

            if (ValidateValues(out nullable, out num, out num2, out num3))
            {
                if (!calendarEndDate.SelectedDate.HasValue)
                {
                    ShowMsg("请选择结束日期!", false);
                }
                else
                {
                    CouponInfo target = new CouponInfo();
                    target.Name          = txtCouponName.Text;
                    target.ClosingTime   = calendarEndDate.SelectedDate.Value;
                    target.Amount        = nullable;
                    target.DiscountValue = num;
                    target.NeedPoint     = num3;
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <CouponInfo>(target, new string[] { "ValCoupon" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                            ShowMsg(msg, false);
                            return;
                        }
                    }
                    string             lotNumber = string.Empty;
                    CouponActionStatus status    = CouponHelper.CreateCoupon(target, num2, out lotNumber);
                    if (status == CouponActionStatus.UnknowError)
                    {
                        ShowMsg("未知错误", false);
                    }
                    else
                    {
                        CouponActionStatus status2 = status;
                        if (status2 == CouponActionStatus.DuplicateName)
                        {
                            ShowMsg("已经存在相同的优惠券名称", false);
                        }
                        else if (status2 == CouponActionStatus.CreateClaimCodeError)
                        {
                            ShowMsg("生成优惠券号码错误", false);
                        }
                        else
                        {
                            if ((status == CouponActionStatus.CreateClaimCodeSuccess) && !string.IsNullOrEmpty(lotNumber))
                            {
                                IList <CouponItemInfo> couponItemInfos = CouponHelper.GetCouponItemInfos(lotNumber);
                                StringWriter           writer          = new StringWriter();
                                writer.WriteLine("优惠券批次号\t优惠券号码\t优惠券金额\t过期时间");
                                foreach (CouponItemInfo info2 in couponItemInfos)
                                {
                                    string str3 = string.Concat(new object[] { lotNumber, "\t", info2.ClaimCode, "\t", target.DiscountValue, "\t", target.ClosingTime });
                                    writer.WriteLine(str3);
                                }
                                writer.Close();
                                Page.Response.AddHeader("Content-Disposition", "attachment; filename=CouponsInfo_" + DateTime.Now + ".xls");
                                Page.Response.ContentType     = "application/ms-excel";
                                Page.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
                                Page.Response.Write(writer);
                                Page.Response.End();
                            }
                            ShowMsg("添加优惠卷成功", true);
                            RestCoupon();
                        }
                    }
                }
            }
        }