Пример #1
0
        public object getLoginUser(Dictionary <string, object> dicParas)
        {
            string UserName = dicParas.ContainsKey("UserName") ? dicParas["UserName"].ToString() : string.Empty;
            string PassWord = dicParas.ContainsKey("PassWord") ? dicParas["PassWord"].ToString() : string.Empty;

            if (string.IsNullOrEmpty(UserName))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请输入用户名"));
            }
            if (string.IsNullOrEmpty(PassWord))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请输入密码"));
            }
            string Pass = Utils.MD5(PassWord);
            IUserRegisterService userervice = BLLContainer.Resolve <IUserRegisterService>();
            var menulist = userervice.GetModels(p => p.UserName == UserName && p.PassWord == Pass).ToList();

            if (menulist.Count > 0)
            {
                if (menulist[0].State != 1)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该用户正在审核中"));
                }
                string key   = UserName;
                string token = System.Guid.NewGuid().ToString("N");
                if (!MobileTokenCache.ExistTokenByKey(key))
                {
                    MobileTokenCache.AddToken(key, token);
                }
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, token, Result_Code.T, ""));
            }
            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户名或密码有误"));
        }
Пример #2
0
        public object merchLogin(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string mobile = dicParas.ContainsKey("mobile") ? dicParas["mobile"].ToString() : string.Empty;
                string code   = dicParas.ContainsKey("smsCode") ? dicParas["smsCode"].ToString() : string.Empty;

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

                string smsCode = dicParas.ContainsKey("smsCode") ? dicParas["smsCode"].ToString() : string.Empty;
                if (string.IsNullOrEmpty(smsCode))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请输入短信验证码"));
                }

                //验证短信验证码
                bool isSMSTest = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["isSMSTest"].ToString());
                //判断缓存验证码是否正确
                string key = mobile + "_" + smsCode;
                if (!isSMSTest)
                {
                    if (!SMSCodeCache.IsExist(key))
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "短信验证码无效"));
                    }
                }

                IMerchService merchService = BLLContainer.Resolve <IMerchService>();
                var           merch        = merchService.GetModels(p => p.Mobile.Equals(mobile, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <Base_MerchInfo>();
                if (merch == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "商户不存在"));
                }

                //如果商户token为空,就写入新的token
                if (string.IsNullOrWhiteSpace(merch.Token))
                {
                    string token = System.Guid.NewGuid().ToString("N");
                    merch.Token = token; //更新token
                    merch.State = 1;     //状态激活
                    merchService.Update(merch);

                    if (!MobileTokenCache.ExistTokenByKey(mobile))
                    {
                        MobileTokenCache.AddToken(CommonConfig.PrefixKey + mobile, token);
                    }
                }

                MerchModel merchModel = new MerchModel(merch.MerchName, merch.OPName, merch.Token, merch.State);
                return(ResponseModelFactory <MerchModel> .CreateModel(isSignKeyReturn, merchModel));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
        public static void SetRS232MobileToken()
        {
            IMerchService mobileTokenService = BLLContainer.Resolve <IMerchService>();
            var           models             = mobileTokenService.GetModels(p => true).ToList().Where(p => !string.IsNullOrWhiteSpace(p.Token)).ToList();

            if (models.Count > 0)
            {
                foreach (var item in models)
                {
                    MobileTokenCache.AddToken(CommonConfig.PrefixKey + item.Mobile, item.Token);
                }
            }
        }
Пример #4
0
        public static void Init()
        {
            IMobileTokenService mobileTokenService = BLLContainer.Resolve <IMobileTokenService>();
            var models = mobileTokenService.GetModels(p => 1 == 1).ToList <t_MobileToken>();

            if (models.Count > 0)
            {
                for (int y = 0; y < models.Count; y++)
                {
                    MobileTokenCache.AddToken(models[y].Phone, models[y].Token);
                }
            }
        }
Пример #5
0
 public static bool ExistToken(string token, out string mobile)
 {
     mobile = string.Empty;
     if (MobileTokenCache.ExistTokenByValue(token))
     {
         mobile = MobileTokenCache.GetKeyByValue(token);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #6
0
        public static string SetMobileToken(string mobile)
        {
            string token = System.Guid.NewGuid().ToString("N");

            if (MobileTokenCache.ExistTokenByKey(mobile))
            {
                SetDBMobileToken(token, mobile);
                MobileTokenCache.UpdateTokenByKey(mobile, token);
            }
            else
            {
                SetDBMobileToken(token, mobile);
                MobileTokenCache.AddToken(mobile, token);
            }
            return(token);
        }