예제 #1
0
        public object checkImgCode(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string mobile = dicParas.ContainsKey("mobile") ? dicParas["mobile"].ToString() : string.Empty;
                string code   = dicParas.ContainsKey("code") ? dicParas["code"].ToString() : string.Empty;
                string sysId  = dicParas.ContainsKey("sysId") ? dicParas["sysId"].ToString() : string.Empty;

                //验证请求次数
                if (!RequestTotalCache.CanRequest(mobile, ApiRequestType.CheckImgCode))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "已超过单日最大请求次数"));
                }
                else
                {
                    RequestTotalCache.Add(mobile, ApiRequestType.CheckImgCode);
                }

                if (!checkCodeParams(dicParas, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                //如果用户未获取验证码
                if (!ValidateImgCache.Exist(code.ToUpper()))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "验证码无效"));
                }

                string key = mobile + "_" + code;
                SMSTempTokenCache.Add(key, mobile, CacheExpires.SMSTempTokenExpires);
                ValidateImgCache.Remove(code.ToUpper());

                SMSTokenModel smsTokenModel = new SMSTokenModel(mobile, code);
                return(ResponseModelFactory <SMSTokenModel> .CreateModel(isSignKeyReturn, smsTokenModel));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
        public object checkStoreImgCode(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg  = string.Empty;
                string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
                string code    = dicParas.ContainsKey("code") ? dicParas["code"].ToString() : string.Empty;
                string sysId   = dicParas.ContainsKey("sysId") ? dicParas["sysId"].ToString() : string.Empty;

                if (string.IsNullOrEmpty(storeId))
                {
                    errMsg = "storeId参数不能为空";
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                if (!Utils.isNumber(storeId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "店号的格式不正确"));
                }

                if (string.IsNullOrEmpty(code))
                {
                    errMsg = "code参数不能为空";
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                int           iStoreId     = Convert.ToInt32(storeId);
                IStoreService storeService = BLLContainer.Resolve <IStoreService>();
                if (!storeService.Any(a => a.id == iStoreId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该门店不存在"));
                }

                var    storeModel = storeService.GetModels(p => p.id == iStoreId).FirstOrDefault();
                string mobile     = storeModel.phone;
                if (string.IsNullOrEmpty(mobile))
                {
                    errMsg = "该门店手机号为空";
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }
                if (!Utils.CheckMobile(mobile))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机格式不正确"));
                }

                //验证请求次数
                if (!RequestTotalCache.CanRequest(mobile, ApiRequestType.CheckImgCode))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "已超过单日最大请求次数"));
                }
                else
                {
                    RequestTotalCache.Add(mobile, ApiRequestType.CheckImgCode);
                }

                //如果用户未获取验证码
                if (!ValidateImgCache.Exist(code.ToUpper()))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "验证码已过期"));
                }

                string key = mobile + "_" + code;
                SMSTempTokenCache.Add(key, mobile, CacheExpires.SMSTempTokenExpires);
                ValidateImgCache.Remove(code.ToUpper());

                string token      = MobileTokenBusiness.SetMobileToken(mobile);
                var    tokenModel = new {
                    token  = token,
                    mobile = mobile.Substring(0, 3) + "****" + mobile.Substring(7), //屏蔽中间4位手机号码
                    code   = code
                };

                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, tokenModel));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #3
0
        public object checkMerch(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string mobile = dicParas.ContainsKey("mobile") ? dicParas["mobile"].ToString() : string.Empty;
                string code   = dicParas.ContainsKey("imgCode") ? dicParas["imgCode"].ToString() : string.Empty;

                if (string.IsNullOrEmpty(mobile))
                {
                    errMsg = "mobile参数不能为空";
                }

                if (string.IsNullOrEmpty(code))
                {
                    errMsg = "验证码不能为空";
                }

                if (!string.IsNullOrEmpty(errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                if (string.IsNullOrWhiteSpace(mobile) || !IsMobile(mobile))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请输入正确的手机号码"));
                }

                //验证请求次数
                if (!RequestTotalCache.CanRequest(mobile, ApiRequestType.CheckImgCode))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "已超过单日最大请求次数"));
                }
                else
                {
                    RequestTotalCache.Add(mobile, ApiRequestType.CheckImgCode);
                }

                //如果用户未获取验证码
                if (!ValidateImgCache.Exist(code.ToUpper()))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "验证码错误"));
                }

                //验证商户手机号码是否存在
                string         sql        = "select Mobile,State from Base_MerchInfo where Mobile=@Mobile";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@Mobile", mobile);
                System.Data.DataSet ds = XCCloudRS232BLL.ExecuteQuerySentence(sql, parameters);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机号码未注册"));
                }
                else if (ds.Tables[0].Rows[0]["state"].ToString() == "0")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该手机号已被禁用"));
                }

                string key = mobile + "_" + code;
                SMSTempTokenCache.Add(key, mobile, CacheExpires.SMSTempTokenExpires);
                ValidateImgCache.Remove(code.ToUpper());

                SMSTokenModel smsTokenModel = new SMSTokenModel(mobile, code);
                return(ResponseModelFactory <SMSTokenModel> .CreateModel(isSignKeyReturn, smsTokenModel));
            }
            catch (Exception e)
            {
                throw e;
            }
        }