コード例 #1
0
        public object login(Dictionary <string, object> dicParas)
        {
            string userMobile = dicParas.ContainsKey("userMobile") ? dicParas["userMobile"].ToString() : string.Empty;
            string password   = dicParas.ContainsKey("password") ? dicParas["password"].ToString() : string.Empty;
            string imgCode    = dicParas.ContainsKey("imgCode") ? dicParas["imgCode"].ToString() : string.Empty;

            //验证码
            if (!ValidateImgCache.Exist(imgCode.ToUpper()))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "验证码无效"));
            }
            ValidateImgCache.Remove(imgCode.ToUpper());

            IAdminUserService adminUserService = BLLContainer.Resolve <IAdminUserService>();
            var model = adminUserService.GetModels(p => p.Mobile.Equals(userMobile)).FirstOrDefault <t_AdminUser>();

            if (model == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户不存在"));
            }
            else
            {
                if (model.Password.Equals(password))
                {
                    string token = XCGameManaAdminUserTokenBusiness.SetToken(model.Mobile, model.Id);
                    var    obj   = new { token = token };
                    return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
                }
                else
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "密码不正确"));
                }
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: Merch.ashx.cs プロジェクト: tongxin3267/XCCloud
        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;
            }
        }
コード例 #4
0
ファイル: Account.ashx.cs プロジェクト: tongxin3267/XCCloud
        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;
            }
        }
コード例 #5
0
        public object getRegisterSMSCode(Dictionary <string, object> dicParas)
        {
            try
            {
                string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
                string mobile  = dicParas.ContainsKey("mobile") ? dicParas["mobile"].ToString() : string.Empty;
                string imgCode = dicParas.ContainsKey("imgCode") ? dicParas["imgCode"].ToString() : string.Empty;
                string errMsg  = string.Empty;

                //验证码
                if (!ValidateImgCache.Exist(imgCode.ToUpper()))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "验证码无效"));
                }
                ValidateImgCache.Remove(imgCode.ToUpper());

                if (string.IsNullOrEmpty(storeId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店号码不正确"));
                }
                if (string.IsNullOrEmpty(mobile))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机号码不正确"));
                }

                bool isSMSTest = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["isSMSTest"].ToString());

                StoreBusiness   sb         = new StoreBusiness();
                StoreCacheModel storeModel = null;
                if (!sb.IsEffectiveStore(storeId, ref storeModel, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }


                if (storeModel.StoreDBDeployType == 0)
                {
                    //验证用户在分库是否存在
                    XCCloudService.BLL.IBLL.XCGame.IUserService userService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IUserService>(storeModel.StoreDBName);
                    var gameUserModel = userService.GetModels(p => p.Mobile.Equals(mobile, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGame.u_users>();
                    if (gameUserModel == null)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "未查询到该用户"));
                    }
                }
                else if (storeModel.StoreDBDeployType == 1)
                {
                    string sn = System.Guid.NewGuid().ToString().Replace("-", "");
                    UDPSocketCommonQueryAnswerModel answerModel = null;
                    string radarToken = string.Empty;
                    if (DataFactory.SendDataUserPhoneQuery(sn, storeModel.StoreID.ToString(), storeModel.StorePassword, mobile, out radarToken, out errMsg))
                    {
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                    }

                    answerModel = null;
                    int whileCount = 0;
                    while (answerModel == null && whileCount <= 25)
                    {
                        //获取应答缓存数据
                        whileCount++;
                        System.Threading.Thread.Sleep(1000);
                        answerModel = UDPSocketCommonQueryAnswerBusiness.GetAnswerModel(sn, 1);
                    }

                    if (answerModel != null)
                    {
                        UserPhoneQueryResultNotifyRequestModel model = (UserPhoneQueryResultNotifyRequestModel)(answerModel.Result);
                        //移除应答缓存数据
                        UDPSocketCommonQueryAnswerBusiness.Remove(sn);
                        if (model.Result_Code == "0")
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "未查询到该用户"));
                        }
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "系统没有响应"));
                    }
                }
                else
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店设置不正确"));
                }

                string templateId = "2";

                string key = string.Empty;
                if (!isSMSTest && !FilterMobileBusiness.ExistMobile(mobile))
                {
                    string smsCode = string.Empty;
                    if (SMSBusiness.GetSMSCode(out smsCode))
                    {
                        key = mobile + "_" + smsCode;
                        SMSCodeCache.Add(key, mobile, CacheExpires.SMSCodeExpires);

                        if (SMSBusiness.SendSMSCode(templateId, mobile, smsCode, out errMsg))
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                        }
                        else
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                        }
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "发送验证码出错"));
                    }
                }
                else
                {
                    key = mobile + "_" + "123456";
                    SMSCodeCache.Add(key, mobile, CacheExpires.SMSCodeExpires);
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }