コード例 #1
0
ファイル: Handler.ashx.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 获取热带风暴门票
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetCardCoupon(HttpContext context)
        {
            string smsVerCode = context.Request["SmsVerCode"];
            var    model      = bllVote.GetVoteObjectInfo(bllVote.BeachHoneyVoteID, CurrentUserInfo.UserID);

            if (model == null)
            {
                resp.errcode = 3;
                resp.errmsg  = "您还没有报名";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            else if (!model.Status.Equals(1))
            {
                resp.errcode = 3;
                resp.errmsg  = "您还未通过审核";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            else if (model.Rank > 1000)
            {
                resp.errcode = 3;
                resp.errmsg  = "您没有获奖";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            //检查是否已经领过了
            int totalCount = 0;

            bllCardCoupon.GetMyCardCoupons(BLLJIMP.Enums.EnumCardCouponType.EntranceTicket, CurrentUserInfo.UserID, 1, 1, out totalCount);

            if (totalCount > 0)
            {
                resp.errcode = 3;
                resp.errmsg  = "您已经领取过热带风暴电子门票了";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrEmpty(smsVerCode))
            {
                resp.errcode = 3;
                resp.errmsg  = "请输入手机验证码";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            var lastVerCode = bllSms.GetLastSmsVerificationCode(model.Phone);

            if (lastVerCode == null)
            {
                resp.errcode = 3;
                resp.errmsg  = "请先获取手机验证码";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            if (smsVerCode != lastVerCode.VerificationCode)
            {
                resp.errcode = 3;
                resp.errmsg  = "手机验证码错误";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            int count = 0;

            if (model.Rank >= 1 && model.Rank <= 10)
            {
                count = 4;//1-到10名 发4张
            }
            if (model.Rank >= 11 && model.Rank <= 100)
            {
                count = 2;//11-到100名 发2张
            }
            if (model.Rank >= 101 && model.Rank <= 1000)
            {
                count = 1;//101-到1000名 发1张
            }
            for (int i = 1; i <= count; i++)
            {
                string Msg = "";
                if (bllCardCoupon.ReciveCoupons(BLLJIMP.Enums.EnumCardCouponType.EntranceTicket, 1, CurrentUserInfo.UserID, out Msg))
                {
                    System.Threading.Thread.Sleep(1000);
                }
                else
                {
                    resp.errcode = 3;
                    resp.errmsg  = Msg;
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
            }



            return(Common.JSONHelper.ObjectToJson(resp));
        }