예제 #1
0
파일: Step1.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string phone   = context.Request["phone"];    //手机号
            string verCode = context.Request["ver_code"]; //验证码

            if (string.IsNullOrEmpty(phone))
            {
                apiResp.msg = "Please Type The Cell Phone";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrEmpty(verCode))
            {
                apiResp.msg = "Please Type The Code";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (context.Session["CheckCode"] == null)
            {
                apiResp.msg = "CheckCode NULL";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (verCode != context.Session["CheckCode"].ToString().ToLower())
            {
                apiResp.msg = "Code Error";
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            //发送验证码到手机
            bool   isSuccess  = false;
            string smsVerCode = new Random().Next(111111, 999999).ToString();
            string msg        = "";

            string smsContent = string.Format("Your verification code {0}", smsVerCode);

            string smsSignature = string.Format("{0}", bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature);//短信签名

            bllSms.SendSmsVerificationCode(phone, smsContent, smsSignature, smsVerCode, out isSuccess, out msg);
            if (isSuccess)
            {
                apiResp.status           = true;
                context.Session["Phone"] = phone;
            }
            else
            {
                apiResp.msg = "Send Fail";
            }
            //发送验证码到手机
            bllUser.ContextResponse(context, apiResp);
        }
예제 #2
0
        /// <summary>
        /// 短信提醒
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string SmsRemind(HttpContext context)
        {
            string promotionActivityId = context.Request["promotion_activity_id"];//限时特卖活动ID
            string phone      = context.Request["phone"];
            string smsContent = context.Request["sms_content"];
            string sendTime   = context.Request["send_time"];

            if (!bllMall.IsLogin)
            {
                resp.errcode = 1;
                resp.errmsg  = "请先登录";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            var currentUserInfo = bllMall.GetCurrentUserInfo();

            if (string.IsNullOrEmpty(promotionActivityId))
            {
                resp.errcode = 1;
                resp.errmsg  = "promotion_activity_id 参数不能为空";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrEmpty(phone))
            {
                resp.errcode = 1;
                resp.errmsg  = "phone 参数不能为空";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if ((!phone.StartsWith("1")) || (!phone.Length.Equals(11)))
            {
                resp.errcode = 2;
                resp.errmsg  = "手机号格式不正确";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrEmpty(smsContent))
            {
                resp.errcode = 1;
                resp.errmsg  = "sms_content 不能为空";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrEmpty(sendTime))
            {
                resp.errcode = 1;
                resp.errmsg  = "send_time 参数不能为空";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            //检查是否已经有记录提醒
            if (IsRemind(promotionActivityId, currentUserInfo.UserID) > 0)
            {
                resp.errcode = 1;
                resp.errmsg  = "已经添加提醒";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            bool   isSuccess    = false;
            string msg          = "";
            string smsSignature = bllSms.GetWebsiteInfoModelFromDataBase().SmsSignature;//短信签名

            if (string.IsNullOrEmpty(smsSignature))
            {
                smsSignature = "至云";
            }
            bllSms.SendSmsMisson(phone, smsContent, sendTime, smsSignature, out isSuccess, out msg);
            if (isSuccess)
            {
                CommRelationInfo model = new CommRelationInfo();
                model.MainId       = promotionActivityId;
                model.RelationId   = currentUserInfo.UserID;
                model.RelationTime = DateTime.Now;
                model.RelationType = "PromotionSmsRemind";
                if (bllMall.Add(model))
                {
                    resp.errcode = 0;
                    resp.errmsg  = "ok";
                }
                else
                {
                    resp.errcode = 4;
                    resp.errmsg  = string.Format("提交提醒失败", msg);
                }
            }
            else
            {
                resp.errcode = 4;
                resp.errmsg  = string.Format("提交失败,错误码{0}", msg);
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }