public ActionResult AccountAdd(AccountAddModel addModel)
 {
     IAccountService accountService = new AccountService();
     var jsonModel = accountService.AddAccount(addModel);
     if (jsonModel.Success)
     {
         return Json(new { success = true, msg = "添加成功", openId=jsonModel.Data.OpenId }, JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(new { success = false, msg = jsonModel.ErrMsg }, JsonRequestBehavior.AllowGet);
     }
 }
        /// <summary>
        /// 添加单点登录的帐号
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonModel<Account> AddAccount(AccountAddModel model)
        {
            JsonModel<Account> jsonModel = new JsonModel<Account>()
            {
                Success = false,
                ErrMsg = "添加失败",
                SuccessMsg = "添加成功"
            };
            try
            {
                //对实体进行验证
                var validate = DotNet.Utils.DataValidate.ValidateHelper<AccountAddModel>.ValidateModel(model);
                if (!validate.Pass)
                {
                    jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage;
                    return jsonModel;
                }
                //过滤
                model.LoginName = DotNet.Utils.Untility.StringHelper.FilterHtml(model.LoginName);
                model.Mobile = DotNet.Utils.Untility.StringHelper.FilterHtml(model.Mobile);
                model.LoginName = DotNet.Utils.Untility.StringHelper.FilterHtml(model.LoginName);

                #region 验证
                if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { LoginName = model.LoginName }))
                {
                    jsonModel.ErrMsg = "用户名已经存在";
                    return jsonModel;
                };
                //验证Mobile
                int mobileBinding = (int)BindingEnum.NotBinded;
                if (!string.IsNullOrEmpty(model.Mobile))
                {
                    if (!DotNet.Utils.Untility.RegexValidate.IsMobileNumber(model.Mobile))
                    {
                        jsonModel.ErrMsg = "手机号码格式不正确";
                        return jsonModel;
                    }
                    mobileBinding=(int)BindingEnum.Binded;
                    if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { Mobile = model.Mobile }))
                    {
                        jsonModel.ErrMsg = "手机号码已经存在";
                        return jsonModel;
                    };
                }
                //验证Email
                 int emailBinding = (int)BindingEnum.NotBinded;
                if (!string.IsNullOrEmpty(model.Email))
                {
                    if (!DotNet.Utils.Untility.RegexValidate.IsEmailAddress(model.Email))
                    {
                        jsonModel.ErrMsg = "Email格式不正确";
                        return jsonModel;
                    }
                    emailBinding=(int)BindingEnum.Binded;
                    if (!BllUtility.AccountHandler.VerifyOnly(new AccountSingleParam() { Email = model.Email }))
                    {
                        jsonModel.ErrMsg = "邮箱已经存在";
                        return jsonModel;
                    };
                }

                //验证安全密码
                int safeBinding = (int)BindingEnum.NotBinded;
                if (!string.IsNullOrEmpty(model.SafePassword))
                {
                    if (!DotNet.Utils.Untility.RegexValidate.IsPasswordOne(model.SafePassword, 6, 25))
                    {
                        jsonModel.ErrMsg = "安全密码格式不正确";
                        return jsonModel;
                    }
                    model.SafePassword = BllUtility.AccountHandler.EncryptSafePassword(model.SafePassword);
                    safeBinding = (int)BindingEnum.Binded;
                }

                //验证提交的域是否存在
                IDomainDal domainDal = new DomainDal();
                var domain = domainDal.GetEntity(new DomainSingleParam() { DomainCode=model.SubmitDomainCode });
                if (domain == null || domain.DomainId <= 0)
                {
                    jsonModel.ErrMsg = "域不存在";
                    return jsonModel;
                }
                #endregion

                string openId = BllUtility.AccountHandler.CreateOpenId();
                string encryptKey = BllUtility.AccountHandler.CreateEncryptKey();
                string encryptPassword = BllUtility.AccountHandler.EncryptPassword(openId, model.Password, encryptKey);
                string mobile = string.IsNullOrEmpty(model.Mobile) ? "" : model.Mobile;
                string email = string.IsNullOrEmpty(model.Email) ? "" : model.Email;
                string safePassword = string.IsNullOrEmpty(model.SafePassword) ? "" : model.SafePassword;
                Account account = new Account()
                {
                    OpenId = openId,
                    LoginName = model.LoginName,
                    EncryptKey = encryptKey,
                    Password = encryptPassword,
                    Mobile = mobile,
                    MobileBinding = mobileBinding,
                    Email = email,
                    EmailBinding = emailBinding,
                    SafePassword = safePassword,
                    SafeBinding = safeBinding,
                    CreateDate = DateTime.Now,
                    DelFlag = (int)DelFlagEnum.Noraml,
                    ReMark = model.ReMark,
                    SubmitDomainId = domain.DomainId
                };
                IAccountDal accountDal = new AccountDal();
                var r = accountDal.AddEntity(account);
                if (r != null && r.AccountId > 0)
                {
                    jsonModel.Success = true;
                    jsonModel.Data = r;
                }
                else
                {
                    jsonModel.ErrMsg = "数据插入失败";
                }
            }
            catch
            {
                jsonModel.ErrMsg = "系统内部错误";
            }

            return jsonModel;
        }