Example #1
0
        /// <summary>
        /// 验证手机或邮箱验证码
        /// </summary>
        /// <param name="checkCode">验证码</param>
        /// <param name="contact">手机号或邮箱</param>
        /// <returns></returns>
        public JsonResult <Result <string> > GetCheckPhoneOrEmailCheckCode(string checkCode, string contact)
        {
            if (string.IsNullOrEmpty(checkCode))
            {
                return(Json(ErrorResult <string>("请输入验证码")));
            }

            PluginInfo pluginInfo;
            var        isMobile = Core.Helper.ValidateHelper.IsMobile(contact);

            if (isMobile)
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();
            }
            else
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(PluginType.Email).First();
            }

            var cache     = CacheKeyCollection.MemberPluginCheck(contact, pluginInfo.PluginId);
            var cacheCode = Core.Cache.Get <string>(cache);

            if (cacheCode != null && cacheCode == checkCode)
            {
                return(OnCheckCheckCodeSuccess(contact));
            }
            else
            {
                return(Json(ErrorResult <string>("验证码输入错误")));
            }
        }
Example #2
0
        public object GetCheckContact(string contact, string certificate)
        {
            CheckShopManageLogin();
            if (!CheckCertificate(certificate))
            {
                return(ErrorResult("凭证无效"));
            }

            PluginInfo pluginInfo;
            var        isMobile = Core.Helper.ValidateHelper.IsMobile(contact);

            if (isMobile)
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();
            }
            else
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(PluginType.Email).First();
            }

            MemberApplication.UpdateMemberContacts(new MemberContacts()
            {
                Contact         = contact,
                ServiceProvider = pluginInfo.PluginId,
                UserId          = CurrentUser.Id,
                UserType        = Himall.Model.MemberContactsInfo.UserTypes.ShopManager
            });

            return(SuccessResult());
        }
Example #3
0
        /// <summary>
        /// 发送手机验证码
        /// </summary>
        /// <param name="imageCheckCode"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        public object GetPhoneCheckCode(string contactsPhone)
        {
            string msg;
            var    checkResult = this.CheckContact(contactsPhone, out msg);

            if (contactsPhone == "")
            {
                return(ErrorResult("请输入手机号"));
            }

            PluginInfo pluginInfo;
            var        isMobile = Core.Helper.ValidateHelper.IsMobile(contactsPhone);

            if (isMobile)
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();
            }
            else
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(PluginType.Email).First();
            }

            if (pluginInfo == null)
            {
                Log.Error(string.Format("未找到{0}发送插件", isMobile ? "短信" : "邮件"));
                return(ErrorResult("验证码发送失败"));
            }

            var timeoutKey = CacheKeyCollection.MemberPluginCheckTime(contactsPhone, pluginInfo.PluginId);

            if (Core.Cache.Get(timeoutKey) != null)
            {
                return(ErrorResult("请求过于频繁,请稍后再试!"));
            }
            int cacheTime = 60;

            Core.Cache.Insert(timeoutKey, cacheTime, DateTime.Now.AddSeconds(cacheTime));

            var checkCode = new Random().Next(10000, 99999);
            var siteName  = Application.SiteSettingApplication.GetSiteSettings().SiteName;
            var message   = new Himall.Core.Plugins.Message.MessageUserInfo()
            {
                UserName = contactsPhone, SiteName = siteName, CheckCode = checkCode.ToString()
            };

            Application.MessageApplication.SendMessageCode(contactsPhone, pluginInfo.PluginId, message);
            //缓存验证码
            Core.Cache.Insert(CacheKeyCollection.MemberPluginCheck(contactsPhone, pluginInfo.PluginId), checkCode, DateTime.Now.AddMinutes(10));

            return(SuccessResult("验证码发送成功"));
        }
        protected override object OnCheckCheckCodeSuccess(string contact)
        {
            CheckUserLogin();

            string pluginId = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First().PluginId;

            var _iMemberIntegralConversionFactoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create;
            var _iMemberIntegralService = ServiceProvider.Instance <IMemberIntegralService> .Create;
            var _iMemberInviteService   = ServiceProvider.Instance <IMemberInviteService> .Create;

            var member = CurrentUser;

            if (Application.MessageApplication.GetMemberContactsInfo(pluginId, contact, MemberContactsInfo.UserTypes.General) != null)
            {
                return(Json(new { success = false, msg = contact + "已经绑定过了!" }));
            }
            member.CellPhone = contact;
            MemberApplication.UpdateMember(member.Map <DTO.Members>());
            Application.MessageApplication.UpdateMemberContacts(new MemberContactsInfo()
            {
                Contact = contact, ServiceProvider = pluginId, UserId = CurrentUser.Id, UserType = MemberContactsInfo.UserTypes.General
            });
            Core.Cache.Remove(CacheKeyCollection.MemberPluginCheck(CurrentUser.UserName, pluginId));
            Core.Cache.Remove(CacheKeyCollection.Member(CurrentUser.Id));            //移除用户缓存
            Core.Cache.Remove("Rebind" + CurrentUser.Id);

            UserMemberInfo inviteMember = null;

            if (member.InviteUserId.HasValue)
            {
                inviteMember = Application.MemberApplication.GetMember(member.InviteUserId.Value);
            }

            MemberIntegralRecord info = new MemberIntegralRecord();

            info.UserName   = member.UserName;
            info.MemberId   = member.Id;
            info.RecordDate = DateTime.Now;
            info.TypeId     = MemberIntegral.IntegralType.Reg;
            info.ReMark     = "绑定手机";
            var memberIntegral = _iMemberIntegralConversionFactoryService.Create(MemberIntegral.IntegralType.Reg);

            _iMemberIntegralService.AddMemberIntegral(info, memberIntegral);
            if (inviteMember != null)
            {
                _iMemberInviteService.AddInviteIntegel(member, inviteMember);
            }

            return(base.OnCheckCheckCodeSuccess(contact));
        }
Example #5
0
        public IEnumerable <IExpress> GetAllExpress()
        {
            IEnumerable <PluginInfo> installedPluginInfos = PluginsManagement.GetInstalledPluginInfos(PluginType.Express);

            IExpress[] expressArray = new IExpress[installedPluginInfos.Count()];
            int        num          = 0;

            foreach (PluginInfo installedPluginInfo in installedPluginInfos)
            {
                string   classFullName = installedPluginInfo.ClassFullName;
                char[]   chrArray      = new char[] { ',' };
                string   str           = classFullName.Split(chrArray)[1];
                IExpress express       = Instance.Get <IExpress>(installedPluginInfo.ClassFullName);
                express.Logo            = string.Concat("/Plugins/Express/", str, "/", express.Logo);
                express.BackGroundImage = string.Concat("/Plugins/Express/", str, "/", express.BackGroundImage);
                int num1 = num;
                num = num1 + 1;
                expressArray[num1] = express;
            }
            return(expressArray);
        }
Example #6
0
        /// <summary>
        /// 验证手机验证码
        /// </summary>
        /// <param name="checkCode">验证码</param>
        /// <param name="contact">手机号或邮箱</param>
        /// <returns></returns>
        public object GetCheckPhoneCheckCode(string checkCode, string contactsPhone)
        {
            if (string.IsNullOrEmpty(checkCode))
            {
                return(ErrorResult("请输入验证码"));
            }

            PluginInfo pluginInfo;

            pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();

            var cache     = CacheKeyCollection.MemberPluginCheck(contactsPhone, pluginInfo.PluginId);
            var cacheCode = Core.Cache.Get(cache);

            if (cacheCode != null && cacheCode.ToString() == checkCode)
            {
                return(OnCheckCheckCodeSuccess(contactsPhone));
            }
            else
            {
                return(ErrorResult("验证码输入错误"));
            }
        }
Example #7
0
        /// <summary>
        /// 发送手机或邮箱验证码
        /// </summary>
        /// <param name="imageCheckCode"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        public JsonResult <Result <int> > GetPhoneOrEmailCheckCode(string contact, string id = null, string imageCheckCode = null, bool checkBind = false)
        {
            if (CurrentUser == null)
            {
                if (string.IsNullOrEmpty(imageCheckCode))
                {
                    return(Json(ErrorResult <int>("请输入验证码")));
                }

                var key             = "ImageCheckCode:" + id;
                var systemCheckCode = Cache.Get <string>(key);
                if (systemCheckCode == null)
                {
                    return(Json(ErrorResult <int>("验证码已过期")));
                }

                if (systemCheckCode.ToLower() != imageCheckCode.ToLower())
                {
                    return(Json(ErrorResult <int>("验证码错误")));
                }
                else
                {
                    Cache.Remove(key);
                }
            }

            string msg;
            var    checkResult = this.CheckContact(contact, out msg);

            if (!checkResult)
            {
                return(Json(ErrorResult <int>(string.IsNullOrEmpty(msg) ? "手机或邮箱号码不存在" : msg)));
            }

            PluginInfo pluginInfo;
            var        isMobile = Core.Helper.ValidateHelper.IsMobile(contact);

            if (isMobile)
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First();
            }
            else
            {
                pluginInfo = PluginsManagement.GetInstalledPluginInfos(PluginType.Email).First();
            }

            if (pluginInfo == null)
            {
                Log.Error(string.Format("未找到{0}发送插件", isMobile ? "短信" : "邮件"));
                return(Json(ErrorResult <int>("验证码发送失败")));
            }

            if (checkBind && Application.MessageApplication.GetMemberContactsInfo(pluginInfo.PluginId, contact, Entities.MemberContactInfo.UserTypes.General) != null)
            {
                return(Json(ErrorResult <int>(contact + "已经绑定过了!")));
            }

            var timeoutKey = CacheKeyCollection.MemberPluginCheckTime(contact, pluginInfo.PluginId);

            if (Core.Cache.Exists(timeoutKey))
            {
                return(Json(ErrorResult <int>("请求过于频繁,请稍后再试!")));
            }
            int cacheTime = 60;

            Core.Cache.Insert(timeoutKey, cacheTime, DateTime.Now.AddSeconds(cacheTime));

            var checkCode = new Random().Next(10000, 99999);
            var siteName  = Application.SiteSettingApplication.SiteSettings.SiteName;
            var message   = new Himall.Core.Plugins.Message.MessageUserInfo()
            {
                UserName = contact, SiteName = siteName, CheckCode = checkCode.ToString()
            };

            Application.MessageApplication.SendMessageCode(contact, pluginInfo.PluginId, message);
            //缓存验证码
            Core.Cache.Insert(CacheKeyCollection.MemberPluginCheck(contact, pluginInfo.PluginId), checkCode.ToString(), DateTime.Now.AddMinutes(10));

            return(JsonResult <int>(msg: "验证码发送成功"));
        }