Beispiel #1
0
 public override object Add(DishAdminUser model)
 {
     //加密密码
     model.login_userpass = DESEncryptTools.GetMd5Base32(model.login_userpass);
     model.addTime        = DateTime.Now;
     return(base.Add(model));
 }
Beispiel #2
0
        public ActionResult StoreEdit(PinStore store, string act = "")
        {
            if (store == null || store.aId <= 0 || store.id <= 0)
            {
                if (act != "save")
                {
                    return(Content("参数错误"));
                }
                else
                {
                    result.code = 0;
                    result.msg  = "参数错误";
                    return(Json(result));
                }
            }
            PinStore model = PinStoreBLL.SingleModel.GetModelByAid_Id(store.aId, store.id);

            if (act != "save")
            {
                return(View(model));
            }
            else
            {
                if (model == null)
                {
                    result.code = 0;
                    result.msg  = "店铺不存在";
                    return(Json(result));
                }
                if (DateTime.Compare(store.endDate, store.startDate) < 0)
                {
                    result.code = 0;
                    result.msg  = "请输入合理的时间范围";
                    return(Json(result));
                }
                model.storeName = store.storeName;
                model.logo      = store.logo;
                model.startDate = store.startDate;
                model.endDate   = store.endDate;
                model.state     = store.state;
                model.rz        = store.rz;
                model.loginName = store.loginName;
                if (!string.IsNullOrEmpty(store.password))
                {
                    model.password = DESEncryptTools.GetMd5Base32(store.password);
                }
                if (PinStoreBLL.SingleModel.Update(model, "storeName,logo,startDate,endDate,state,rz,loginName,password"))
                {
                    result.code = 1;
                    result.msg  = "保存成功";
                    return(Json(result));
                }
                else
                {
                    result.code = 0;
                    result.msg  = "保存失败";
                    return(Json(result));
                }
            }
        }
Beispiel #3
0
 public ActionResult ResetPwd(string act = "", string loginname = "", string password = "", string authCode = "", int aid = 0)
 {
     if (!string.IsNullOrEmpty(act))
     {
         if (act == "reset")
         {
             PinStore store = PinStoreBLL.SingleModel.GetStoreByPhone(loginname);
             if (store == null)
             {
                 result.msg = "店铺不存在,请检查手机号码是否正确";
                 return(Json(result));
             }
             string code = RedisUtil.Get <string>(loginname);
             if (code == "" || authCode == "" || code != authCode)
             {
                 result.msg = "验证码错误";
                 return(Json(result));
             }
             store.password = DESEncryptTools.GetMd5Base32(password);
             if (PinStoreBLL.SingleModel.Update(store, "password"))
             {
                 result.msg = "密码重置成功,请登陆";
             }
             else
             {
                 result.msg = "重置失败,请重试";
             }
             return(Json(result));
         }
     }
     return(View());
 }
Beispiel #4
0
        public ActionResult PerfectData()
        {
            Account account = AccountBLL.SingleModel.GetModel(dzuserId);

            ViewBag.LoginId    = account.LoginId;
            ViewBag.IsUpdateId = account.IsUpdateId;
            ViewBag.Title      = "用户资料";
            ViewBag.Path       = ViewBag.Title;
            ViewBag.NavName    = ViewBag.Title;

            Member member = bllMember.GetModel(string.Format("AccountId='{0}'", dzuserId));// membersFromCRM.GetMemberModel(string.Format("AccountId='{0}'", guserId));//xrl要调用加密接口

            //解密
            member.ConsigneePhone1 = DESEncryptTools.GetMd5Base32(member.ConsigneePhone1);
            member.EMail           = DESEncryptTools.GetMd5Base32(member.EMail);
            //---加**号
            member.ConsigneePhone1 = commonCore.PhoneToNickName(member.ConsigneePhone1);
            member.EMail           = commonCore.EMaliToNickName(member.EMail);

            ViewBag.PassWord = account.Password;// "E10ADC3949BA59ABBE56E057F20F883E";
            long sessonid = Utility.CheckSum.ComputeCheckSum("resetpassword:"******"resetpassword:" + sessonid.ToString(), new { OpenId = account.OpenId, IsScan = 0 }, TimeSpan.FromHours(3));
            return(View(member));
        }
Beispiel #5
0
        public JsonResult EditStore(Account account, DishStore store, [System.Web.Http.FromBody] EditStore edit)
        {
            if (DishStoreBLL.SingleModel.CheckExistLoginName(store.id, store.aid, edit.Login))
            {
                //请输入门店管理员账号
                return(ApiModel(message: "存在同名的管理者账号,请修改!"));
            }

            store.updateTime      = DateTime.Now;
            store.dish_name       = edit.Name;
            store.dish_logo       = edit.Logo;
            store.dish_begin_time = edit.Begin.Value;
            store.dish_end_time   = edit.Expire.Value;
            store.login_username  = edit.Login;
            string updateColumns = "dish_name,dish_logo,dish_begin_time,dish_end_time,login_username,updateTime";

            if (!string.IsNullOrEmpty(edit.Password))
            {
                updateColumns       += ",login_userpass";
                store.login_userpass = DESEncryptTools.GetMd5Base32(edit.Password);
            }
            bool success = DishStoreBLL.SingleModel.Update(store, updateColumns);

            return(ApiModel(isok: success, message: success ? "更新成功" : "更新失败"));
        }
Beispiel #6
0
        /// <summary>
        /// 用户扫描代理分销二维码进行注册时,有可能已存在账号,该方法是修改用户一些信息
        /// </summary>
        /// <param name="accountid"></param>
        /// <param name="phone"></param>
        /// <param name="password"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public bool UpdateUserInfo(string accountid, string phone, string password, string address)
        {
            TransactionModel tran        = new TransactionModel();
            string           passwordMd  = DESEncryptTools.GetMd5Base32(password);
            Member           membermodel = MemberBLL.SingleModel.GetMemberByAccountId(accountid);

            MySqlParameter[] param = new MySqlParameter[] {
                new MySqlParameter("@ConsigneePhone", phone),
                new MySqlParameter("@Password", passwordMd),
                new MySqlParameter("@id", accountid),
            };
            tran.Add($"update Account set ConsigneePhone=@ConsigneePhone,Password=@Password where id=@id", param);

            if (membermodel != null)
            {
                MySqlParameter[] param2 = new MySqlParameter[] {
                    new MySqlParameter("@ConsigneePhone1", phone),
                    new MySqlParameter("@CompanyRemark", address),
                    new MySqlParameter("@AccountId", accountid),
                };
                tran.Add($"update Member set ConsigneePhone1=@ConsigneePhone1,CompanyRemark=@CompanyRemark where AccountId=@AccountId", param2);
            }

            return(base.ExecuteTransaction(tran.sqlArray, tran.ParameterArray));
        }
Beispiel #7
0
 public PinStore GetAdminByLoginParams(string loginName, string password)
 {
     MySqlParameter[] paras = new MySqlParameter[] {
         new MySqlParameter("@loginName", loginName),
         new MySqlParameter("@password", DESEncryptTools.GetMd5Base32(password)),
     };
     return(base.GetModel(" loginName = @loginName and password = @password and state=1 ", paras));
 }
Beispiel #8
0
        public override bool Update(DishAdminUser model)
        {
            //加密密码
            if (!model.login_userpass.IsNullOrWhiteSpace())
            {
                model.login_userpass = DESEncryptTools.GetMd5Base32(model.login_userpass);
            }

            return(base.Update(model));
        }
Beispiel #9
0
        public override bool Update(DishAdminUser model, string columns)
        {
            if (columns.IsNullOrWhiteSpace())
            {
                return(false);
            }

            //加密密码
            if (columns.Split(',').Contains("login_userpass") && !model.login_userpass.IsNullOrWhiteSpace())
            {
                model.login_userpass = DESEncryptTools.GetMd5Base32(model.login_userpass);
            }
            return(base.Update(model, columns));
        }
Beispiel #10
0
 public DishStore GetAdminByLoginParams(string login_username, string login_userpass)
 {
     try
     {
         MySqlParameter[] paras = new MySqlParameter[] {
             new MySqlParameter("@login_username", login_username),
             new MySqlParameter("@login_userpass", DESEncryptTools.GetMd5Base32(login_userpass)),
         };
         DishStore admin = base.GetModel(" login_username = @login_username and login_userpass = @login_userpass  ", paras);
         return(admin);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #11
0
 public AuthRole UserLogin(int appId, string loginName, string password)
 {
     try
     {
         MySqlParameter[] paras = new MySqlParameter[] {
             new MySqlParameter("@AppId", appId),
             new MySqlParameter("@LoginName", loginName),
             new MySqlParameter("@Password", DESEncryptTools.GetMd5Base32(password))
         };
         return(GetModel("LoginName = @LoginName AND Password = @PassWord AND aId = @AppId AND State != -1", paras));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #12
0
        /// <summary>
        /// 开通多门店时初始化店铺数据
        /// </summary>
        /// <param name="scount">开通门店数量</param>
        /// <param name="accountid">用户accountid</param>
        /// <param name="rid">模板权限ID</param>
        /// <returns></returns>
        public List <string> GetAddMiniAccountSQL(int scount, string accountid, int rid, int storeid = 0)
        {
            List <string> sqllist     = new List <string>();
            MiniAccount   miniaccount = new MiniAccount();

            if (scount > 0)
            {
                if (storeid == 0)
                {
                    miniaccount = new MiniAccount()
                    {
                        AccountId    = accountid,
                        ParentId     = storeid,
                        TemplateId   = rid,
                        LoginId      = "",
                        CreationDate = DateTime.Now
                    };
                    storeid = Convert.ToInt32(Add(miniaccount));
                }

                dzlogin             = "******" + DateTime.Now.ToString("yyyyMMddHHmmss");
                miniaccount.LoginId = dzlogin;
                var pwd = DESEncryptTools.GetMd5Base32("123456");
                for (int i = 0; i < scount; i++)
                {
                    miniaccount = new MiniAccount()
                    {
                        AccountId    = accountid,
                        ParentId     = storeid,
                        TemplateId   = rid,
                        LoginId      = GetUserLoginId(miniaccount.LoginId, dzlogin),
                        Password     = pwd,
                        DayBegin     = DateTime.Now,
                        DayEnd       = DateTime.Now.AddYears(1),
                        CreationDate = DateTime.Now
                    };

                    sqllist.Add(BuildAddSql(miniaccount));
                }
            }

            return(sqllist);
        }
Beispiel #13
0
 /// <summary>
 /// 鹏讯官网用户登录 传输过来的数据不要经过任何加密
 /// </summary>
 /// <param name="LoginName">用户名</param>
 /// <param name="PassWord">用户密码</param>
 /// <param name="memberType">用户类型</param>
 /// <returns>返回用户实体</returns>
 public Account LoginUserWhole(string LoginName, string PassWord)
 {
     try
     {
         MySqlParameter[] paras = new MySqlParameter[] {
             new MySqlParameter("@loginName", LoginName),
             new MySqlParameter("@ConsigneePhone", LoginName),
             new MySqlParameter("@Password", DESEncryptTools.GetMd5Base32(PassWord))
             //  new MySqlParameter("@Password",PassWord)
         };
         //---检测 手机/邮箱
         Account account = base.GetModel(" (LoginId=@loginName || ConsigneePhone=@ConsigneePhone) and Password=@Password and Status=1 ", paras);
         //   Account account = base.GetModel(" (LoginId=@loginName || ConsigneePhone=@ConsigneePhone) and Password='******' and Status=1 ", paras);//测试优惠券同步到微信卡包账号
         return(account);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #14
0
        public ActionResult UpdateAccount(DishStore store, string login, string password)
        {
            if (string.IsNullOrEmpty(login))
            {
                return(ApiModel(message: "登录名不能为空"));
            }

            store.login_username = login;
            string updateField = "login_username";

            if (!string.IsNullOrWhiteSpace(password))
            {
                store.login_userpass = DESEncryptTools.GetMd5Base32(password);
                updateField         += ",login_userpass";
            }

            bool success = DishStoreBLL.SingleModel.Update(store, updateField);

            return(ApiModel(isok: success, message: success ? "操作成功" : "操作失败"));
        }
Beispiel #15
0
        public Account WeiXinRegister(string OpenId, int usertype, string Unionid = null, bool ismobilereg = false, string address = "", string phone = "", string sourcefrom = "", string password = "******")
        {
            Account account = null;

            if ((Unionid != null && !string.IsNullOrEmpty(Unionid)) || ismobilereg)
            {
                account = GetModel(string.Format(" Unionid='{0}' ", Unionid));
                //Account account = bllAccount.GetModel(string.Format(" OpenId='{0}' ", OpenId));
                if (account != null && !ismobilereg)
                {
                    return(account);
                }
                account                = new Account();
                account.OpenId         = OpenId;
                account.UnionId        = Unionid;
                account.ConsigneePhone = phone;
                ////判断是否是普通用户注册,如果是0普通用户注册,则必须要验证手机号码,才能启用账号
                //account.Status = usertype == 1 ? false : true;
                //--生成随机唯一登录ID
                account.LoginId = GenerateRandomLoginId("vzan", 8);
                //---密码加密MD5
                account.Password = DESEncryptTools.GetMd5Base32(password);
                Member member = new Member()
                {
                    AccountId = account.Id
                };
                member.ConsigneePhone1 = phone;
                member.CompanyRemark   = address;
                member.Avatar          = sourcefrom;
                //--随机唯一登录ID 座位默认昵称
                member.MemberName = account.LoginId;
                base.Add(account);                 //添加用户账户表
                MemberBLL.SingleModel.Add(member); //添加用户信息表
                //建立关联
                AccountRelation accountrelaton = new AccountRelation();
                accountrelaton.AccountId = account.Id.ToString();
                accountrelaton.AddTime   = DateTime.Now;
                AccountRelationBLL.SingleModel.Add(accountrelaton);
            }
            return(account);
        }
Beispiel #16
0
        /// <summary>
        /// 回调签名规则
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public string GetSignatureR(object obj)
        {
            string signature = "";

            PropertyInfo[] pros             = obj.GetType().GetProperties();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            if (pros != null && pros.Length > 0)
            {
                foreach (PropertyInfo pro in pros)
                {
                    if (pro.Name == "signature")
                    {
                        continue;
                    }

                    Object value = pro.GetValue(obj);
                    if (value == null || value == DBNull.Value || string.IsNullOrEmpty(value.ToString()))
                    {
                        dic.Add(pro.Name, "");
                        continue;
                    }

                    dic.Add(pro.Name, value.ToString());
                }

                if (dic.Count > 0)
                {
                    //第一步:将参与签名的参数按照键值(value)进行字典排序
                    //第二步:将排序过后的参数,进行value字符串拼接
                    signature = string.Join("", dic.OrderBy(x => x.Value).Select(x => x.Value));
                    //第四步:对签名字符串进行MD5加密,生成32位的字符串
                    signature = DESEncryptTools.GetMd5Base32(signature);
                }
            }

            return(signature);
        }
Beispiel #17
0
        public JsonResult AddStore(Account account, [System.Web.Http.FromBody] EditStore edit, int?aId)
        {
            if (!aId.HasValue)
            {
                return(ApiModel(message: "参数不能为空_aId"));
            }
            if (string.IsNullOrEmpty(edit.Password))
            {
                return(ApiModel(message: "密码不能为空"));
            }

            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(aId.Value, account.Id.ToString());

            int storeCount = DishStoreBLL.SingleModel.GetCount($"aid={app.Id} and state<>-1");

            if (storeCount >= app.SCount)
            {
                return(ApiModel(message: $"门店数量已达到上限,您最多只能创建{app.SCount}个门店"));
            }

            DishStore store = new DishStore
            {
                updateTime      = DateTime.Now,
                dish_name       = edit.Name,
                dish_logo       = edit.Logo,
                dish_begin_time = edit.Begin.Value,
                dish_end_time   = edit.Expire.Value,
                login_username  = edit.Login,
                //如果只能创建一个门店,默认设置为主店
                ismain         = app.SCount <= 1 && storeCount == 0 ? 1 : 0,
                login_userpass = DESEncryptTools.GetMd5Base32(edit.Password),
                aid            = app.Id,
            };
            int  newId   = 0;
            bool success = int.TryParse(DishStoreBLL.SingleModel.Add(store)?.ToString(), out newId) && newId > 0;

            return(ApiModel(isok: success, message: success ? "新增成功" : "新增失败"));
        }
Beispiel #18
0
        /// <summary>
        /// 账号设置,密码修改
        /// </summary>
        /// <returns></returns>
        public ActionResult AccountEdit(string act = "", int aId = 0, int storeId = 0, string password = "", string repassword = "")
        {
            PinStore store = (PinStore)Request.RequestContext.RouteData.Values["pinStore"];

            if (store == null)
            {
                return(Content("门店不存在!"));
            }

            if (string.IsNullOrEmpty(act))
            {
                if (aId <= 0)
                {
                    result.code = 500;
                    result.msg  = "参数错误";
                    return(View("PageError", result));
                }
                if (storeId <= 0)
                {
                    result.code = 500;
                    result.msg  = "参数错误!";
                    return(View("PageError", result));
                }
                return(View(store));
            }
            else if (act == "save")
            {
                if (!ModelState.IsValid)
                {
                    result.msg = this.ErrorMsg();
                    return(Json(result));
                }
                if (!string.IsNullOrEmpty(password))
                {
                    if (!password.Equals(repassword))
                    {
                        result.msg = "密码不一致";
                        return(Json(result));
                    }
                    else
                    {
                        store.password = DESEncryptTools.GetMd5Base32(password);
                    }

                    bool isSuccess = PinStoreBLL.SingleModel.Update(store, "password");
                    if (isSuccess)
                    {
                        result.code = 1;
                        result.msg  = "保存成功";
                    }
                    else
                    {
                        result.code = 0;
                        result.msg  = "保存失败";
                    }
                }
                else
                {
                    result.msg = "请输入要修改的密码";
                }
            }
            return(Json(result));
        }
Beispiel #19
0
        public ActionResult Edit(string act = "", int id = 0, int aId = 0, int storeId = 0, DishStore model = null, string pwd = "")
        {
            XcxAppAccountRelation xcx = (XcxAppAccountRelation)Request.RequestContext.RouteData.Values["xcx"];

            //参数验证
            if (aId <= 0)
            {
                _result.msg = "参数错误";
                return(Json(_result));
            }
            //显示
            if (string.IsNullOrEmpty(act))
            {
                if (id == 0)
                {
                    model = new DishStore();
                }
                else
                {
                    model = DishStoreBLL.SingleModel.GetModel(id);
                    if (model == null)
                    {
                        return(Content("分类不存在"));
                    }
                }
                EditModel <DishStore> em = new EditModel <DishStore>();
                em.DataModel             = model;
                em.aId                   = aId;
                em.storeId               = storeId;
                ViewBag.dishCategoryList = DishCategoryBLL.SingleModel.GetList($"state=1 and type=1 and aid={aId}");
                return(View(em));
            }
            else
            {
                if (act == "edit")
                {
                    if (string.IsNullOrEmpty(model.login_username))
                    {
                        _result.code = 0;
                        _result.msg  = "请输入门店管理员账号";
                        return(Json(_result));
                    }

                    if (DishStoreBLL.SingleModel.CheckExistLoginName(id, aId, model.login_username))
                    {
                        _result.code = 0;
                        _result.msg  = "存在同名的管理者账号,请修改!";
                        return(Json(_result));
                    }

                    if (id == 0)
                    {
                        int count = DishStoreBLL.SingleModel.GetCount($"aid={xcx.Id} and state<>-1");
                        if (count >= xcx.SCount)
                        {
                            _result.msg = $"您最多只能创建{xcx.SCount}个门店!";
                            return(Json(_result));
                        }
                        //如果只能创建一个门店,默认设置为主店
                        if (xcx.SCount <= 1)
                        {
                            model.ismain = 1;
                        }
                        if (string.IsNullOrEmpty(pwd))
                        {
                            _result.msg = "密码不能为空!";
                            return(Json(_result));
                        }
                        model.login_userpass = DESEncryptTools.GetMd5Base32(pwd);
                        model.id             = Convert.ToInt32(DishStoreBLL.SingleModel.Add(model));
                    }
                    else
                    {
                        string updateColumns = "dish_cate_id,dish_name,dish_logo,dish_con_mobile,dish_con_phone,dish_begin_time,dish_end_time,cash_fee,login_username";
                        if (!string.IsNullOrEmpty(pwd))
                        {
                            updateColumns       += ",login_userpass";
                            model.login_userpass = DESEncryptTools.GetMd5Base32(pwd);
                        }
                        model.updateTime = DateTime.Now;
                        DishStoreBLL.SingleModel.Update(model, updateColumns);
                    }


                    _result.code = 1;
                    _result.msg  = "保存成功";
                    return(Json(_result));
                }
            }
            return(Json(_result));
        }
Beispiel #20
0
        public JsonResult UpdateRole(AuthInfo authInfo = null, int?aId = null, AuthRole updateRole = null, bool isChangePwd = false)
        {
            if (updateRole == null)
            {
                result.msg = "提交数据为空";
                return(Json(result));
            }
            if (updateRole.Id > 0 && updateRole.AId != aId.Value)
            {
                result.msg = "非法操作";
                return(Json(result));
            }
            if (string.IsNullOrWhiteSpace(updateRole.Name))
            {
                result.msg = "名称不能为空";
                return(Json(result));
            }
            if (updateRole.GroupId <= 0)
            {
                result.msg = "账号分组不能为空";
                return(Json(result));
            }
            if (string.IsNullOrWhiteSpace(updateRole.LoginName))
            {
                result.msg = "登陆用户名不能为空";
                return(Json(result));
            }
            if (updateRole.LoginName.Length < 6)
            {
                result.msg = "登录名长度至少6个字符";
                return(Json(result));
            }
            if (!string.IsNullOrWhiteSpace(updateRole.Password) && updateRole.Password.Length < 6)
            {
                result.msg = "密码长度至少6个字符";
                return(Json(result));
            }
            if (updateRole.Id == 0 && !AuthRoleBLL.SingleModel.CheckLoginName(aId.Value, updateRole.LoginName))
            {
                result.msg = "该登录用户名已使用,请重新选一个";
                return(Json(result));
            }
            bool isSuccess = false;

            if (updateRole.Id > 0)
            {
                string pwdField = isChangePwd ? ",Password" : string.Empty;
                updateRole.Password = isChangePwd ? DESEncryptTools.GetMd5Base32(updateRole.Password) : string.Empty;
                isSuccess           = AuthRoleBLL.SingleModel.Update(updateRole, $"Name,GroupId,Remark{pwdField}");
            }
            else
            {
                updateRole.Password     = string.IsNullOrWhiteSpace(updateRole.Password) ? "123456" : updateRole.Password;
                updateRole.Password     = DESEncryptTools.GetMd5Base32(updateRole.Password);
                updateRole.CreateUserId = authInfo.AuthAdmin != null ? authInfo.AuthAdmin.Id : 0;
                updateRole.AId          = aId.Value;
                updateRole.AddTime      = DateTime.Now;
                isSuccess = int.Parse(AuthRoleBLL.SingleModel.Add(updateRole).ToString()) > 0;
            }
            result.code = isSuccess ? 1 : 0;
            return(Json(result));
        }