예제 #1
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));
        }
예제 #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));
                }
            }
        }
예제 #3
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 ? "更新成功" : "更新失败"));
        }
예제 #4
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());
 }
예제 #5
0
        public JsonResult MasterLogin(string username, string password, string wxToken = null)
        {
            bool wxLogin  = !string.IsNullOrWhiteSpace(wxToken);
            bool hasInput = !string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password);

            if (!wxLogin && !hasInput)
            {
                return(ApiModel(message: "用户名和密码不能为空"));
            }

            Account    account  = null;
            C_UserInfo userInfo = null;

            if (wxLogin)
            {
                //微信授权登陆
                wxToken = HttpUtility.UrlDecode(wxToken);
                int userId;
                int.TryParse(DESEncryptTools.DESDecrypt(wxToken), out userId);
                userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);
                account  = AccountBLL.SingleModel.GetAccountByUnionId(userInfo.UnionId);
            }

            string loginToken = string.Empty;
            string authToken  = string.Empty;

            if (account != null)
            {
                //登陆已绑定微信的账号
                authToken  = DESEncryptTools.DESEncrypt(account.Id.ToString());
                loginToken = Utils.BuildCookie(account.Id, account.UpdateTime);
            }
            else if (hasInput)
            {
                bool success = false;
                //用账号密码登录账号
                account = AccountBLL.SingleModel.LoginUserWhole(username, password);
                if (account == null)
                {
                    return(ApiModel(message: "用户名或密码错误"));
                }
                if (userInfo != null)
                {
                    account.UnionId = userInfo.UnionId;
                    success         = AccountBLL.SingleModel.Update(account, "UnionId");
                }
                if (userInfo != null && account != null && !success)
                {
                    return(ApiModel(message: "账号绑定微信失败"));
                }
                authToken  = DESEncryptTools.DESEncrypt(account.Id.ToString());
                loginToken = Utils.BuildCookie(account.Id, account.UpdateTime);
            }
            else
            {
                return(ApiModel(isok: true, message: "微信账号未绑定账号,请输入账号密码", data: "NewUser"));
            }

            return(ApiModel(isok: true, message: "登陆成功", data: new { loginToken, authToken }));
        }
예제 #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));
        }
예제 #7
0
        /// <summary>
        /// 最高管理权限
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static bool IsMasterAuth(Account account)
        {
            string masterAuth = CookieHelper.GetCookie("masterAuth");
            string authToken  = DESEncryptTools.DESDecrypt(masterAuth);

            return(authToken == account.Id.ToString());
        }
예제 #8
0
 public override object Add(DishAdminUser model)
 {
     //加密密码
     model.login_userpass = DESEncryptTools.GetMd5Base32(model.login_userpass);
     model.addTime        = DateTime.Now;
     return(base.Add(model));
 }
예제 #9
0
        public static Guid GetBuildCookieId(string cookieName)
        {
            string cookie = CookieHelper.GetCookie(cookieName);

            if (string.IsNullOrEmpty(cookie))
            {
                return(Guid.Empty);
            }

            if (!string.IsNullOrEmpty(cookie))
            {
                cookie = DESEncryptTools.DESDecrypt(cookie);
            }
            Guid cookieId = Guid.Empty;

            if (!string.IsNullOrEmpty(cookie))
            {
                List <string> kv = cookie.SplitStr(@"\r\n");
                if (kv.Count == 2 && !string.IsNullOrEmpty(kv[0]) && !string.IsNullOrEmpty(kv[1]))
                {
                    Guid.TryParse(kv[0], out cookieId);
                }
            }
            return(cookieId);
        }
예제 #10
0
        public ActionResult Index(int?appId = null, string username = null, string password = null, bool isKeep = false, string backurl = null)
        {
            if (!appId.HasValue)
            {
                result.msg = "参数不能为空_appId";
                return(Json(result));
            }

            //清除缓存
            CookieHelper.Remove("dz_UserCookieNew");
            Response.ContentEncoding = Encoding.UTF8;
            username = StringHelper.NoHtml(username.Trim());
            password = StringHelper.NoHtml(password);

            AuthRole admin = AuthRoleBLL.SingleModel.UserLogin(appId.Value, username, password);

            if (admin == null)
            {
                result.msg = "用户名或密码错误";
                return(Json(result));
            }

            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModel(admin.AId);

            if (app == null)
            {
                result.msg = "小程序不存在";
                return(Json(result));
            }
            Account account = AccountBLL.SingleModel.GetModel(app.AccountId);

            if (account == null)
            {
                result.msg = "授权账号不存在";
                return(Json(result));
            }

            Session["userName"]    = username;
            Session["passWord"]    = password;
            Session["dzAccountId"] = account.Id.ToString();
            if (isKeep)//--保存本地用户名
            {
                CookieHelper.SetCookie("LoginUserName", HttpUtility.UrlEncode(username));
            }
            else
            {
                CookieHelper.Remove("LoginUserName");
            }

            Task.Factory.StartNew(() =>
            {
                AuthRoleBLL.SingleModel.UpdateLoginTime(admin);
            });

            result.code = 1;
            result.msg  = "登陆成功";
            result.obj  = new { loginToken = account.Id, authToken = DESEncryptTools.DESEncrypt(admin.Id.ToString()), url = $"/pin/main?Id={app.Id}&appId={app.Id}" };
            return(Json(result));
        }
예제 #11
0
 public string BuildCookie(Agentinfo agentinfo)
 {
     if (agentinfo == null)
     {
         return(string.Empty);
     }
     return(DESEncryptTools.DESEncrypt($@"{agentinfo.useraccountid}\r\n{agentinfo.updateitme.ToString("yyyy-MM-dd HH:mm:ss")}"));
 }
예제 #12
0
파일: PinStoreBLL.cs 프로젝트: soon14/vzan
 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));
 }
예제 #13
0
        public override bool Update(DishAdminUser model)
        {
            //加密密码
            if (!model.login_userpass.IsNullOrWhiteSpace())
            {
                model.login_userpass = DESEncryptTools.GetMd5Base32(model.login_userpass);
            }

            return(base.Update(model));
        }
예제 #14
0
파일: LoginFilter.cs 프로젝트: soon14/vzan
        private DishStore GetStoreByAuth(AuthorizationContext filterContext)
        {
            int    manageStoreId = 0;
            string loginToken    = CookieHelper.GetCookie("dzDishAdmin");

            if (!int.TryParse(DESEncryptTools.DESDecrypt(loginToken), out manageStoreId) || manageStoreId <= 0)
            {
                return(null);
            }
            return(DishStoreBLL.SingleModel.GetModel(manageStoreId));
        }
예제 #15
0
        /// <summary>
        /// 子帐号权限
        /// </summary>
        /// <returns></returns>
        public static AuthRole GetAdminAuth()
        {
            string adminAuth      = CookieHelper.GetCookie("adminAuth");
            string adminAuthToken = DESEncryptTools.DESDecrypt(adminAuth);
            int    roleId         = 0;

            if (int.TryParse(adminAuthToken, out roleId) && roleId > 0)
            {
                return(AuthRoleBLL.SingleModel.GetModel(roleId));
            }
            return(null);
        }
예제 #16
0
파일: MemberBLL.cs 프로젝트: soon14/vzan
        /// <summary>
        /// 注册会员信息
        /// </summary>
        /// <param name="AccountId">帐号ID</param>
        /// <param name="Phone">电话</param>
        /// <param name="CellPhone">手机</param>
        /// <param name="Referrer">推荐人</param>
        /// <returns>返回是否成功</returns>
        public bool InsertRegInfo(Guid AccountId, string Phone, string CellPhone)
        {
            Member member = new Member();

            member.Id              = new Guid();
            member.AccountId       = AccountId;
            member.ConsigneePhone1 = DESEncryptTools.Encrypt(Phone);
            member.ConsigneePhone2 = DESEncryptTools.Encrypt(CellPhone);
            member.Sex             = 0;
            member.Birthday        = DateTime.Now;
            member.SyncStatus      = "I";
            return((int)Add(member) > 0);
        }
예제 #17
0
        public ActionResult WeChatLogin(string sessionGUID)
        {
            OAuthUserInfo oauthInfo = WxOAuth.SingleModel.GetOAuthInfo(sessionGUID);

            if (oauthInfo == null)
            {
                return(Content("错误"));
            }

            C_UserInfo userInfo   = C_UserInfoBLL.SingleModel.GetModelFromCache(oauthInfo.openid);
            C_UserInfo updateUser = new C_UserInfo
            {
                NickName   = oauthInfo.nickname,
                HeadImgUrl = oauthInfo.headimgurl,
                Address    = $"{oauthInfo.country}{oauthInfo.province}{oauthInfo.city}",
                OpenId     = oauthInfo.openid,
                UnionId    = oauthInfo.unionid,
                Sex        = oauthInfo.sex,
                Remark     = "公众号移动端授权用户",
                AddTime    = DateTime.Now,
                UpdateTime = DateTime.Now,
            };

            if (userInfo?.Id > 0)
            {
                C_UserInfoBLL.SingleModel.Update(updateUser, "NickName,HeadImgUrl,Address,Sex,UpdateTime");
                updateUser.Id = userInfo.Id;
            }
            else
            {
                int newId;
                if (!int.TryParse(C_UserInfoBLL.SingleModel.Add(updateUser)?.ToString(), out newId) || newId == 0)
                {
                    return(Content("保存用户信息失败"));
                }
                updateUser.Id = newId;
            }

            string  loginType = string.Empty;
            Account account   = AccountBLL.SingleModel.GetAccountByUnionId(updateUser.UnionId);

            if (!string.IsNullOrWhiteSpace(account?.Id.ToString()))
            {
                //已绑定小程序管理账号
                loginType = "master";
            }

            string loginToken = DESEncryptTools.DESEncrypt(updateUser.Id.ToString());

            return(Redirect($"/Shop/Admin#/?token={HttpUtility.UrlEncode(loginToken)}&type={loginType}"));
        }
예제 #18
0
파일: LoginFilter.cs 프로젝트: soon14/vzan
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //TODO 开发阶段屏蔽登陆验证
            //return;
            if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
            {
                return;
            }

            int storeId = Context.GetRequestInt("storeId", 0);

            if (storeId > 0)
            {
                string cookieSoreId = CookieHelper.GetCookie("dzPinAdmin");
                //如果没有找到登陆cookie
                if (string.IsNullOrEmpty(cookieSoreId))
                {
                    filterContext.Result = new RedirectResult("/PinAdmin/main/login");
                    return;
                }
                int storeid = 0;
                int.TryParse(DESEncryptTools.DESDecrypt(cookieSoreId), out storeid);
                //如果登陆cookie无法解密
                if (storeid <= 0)
                {
                    filterContext.Result = new RedirectResult("/PinAdmin/main/login");
                    return;
                }
                //只能进对应的管理后台
                if (storeid != storeId)
                {
                    filterContext.Result = new RedirectResult("/PinAdmin/main/login");
                    return;
                }

                PinStore pinStore = PinStoreBLL.SingleModel.GetModel(storeid);
                //如果门店不存在
                if (pinStore == null)
                {
                    filterContext.Result = new RedirectResult("/PinAdmin/main/login");
                    return;
                }

                filterContext.RouteData.Values["pinStore"] = pinStore;
            }
            else
            {
                filterContext.Result = new RedirectResult("/PinAdmin/main/login");
                return;
            }
        }
예제 #19
0
        public static bool IsPinAdmin()
        {
            int    storeId       = Context.GetRequestInt("storeId", 0);
            string cookieStoreId = CookieHelper.GetCookie("dzPinAdmin");

            if (storeId == 0 || string.IsNullOrWhiteSpace(cookieStoreId))
            {
                return(false);
            }
            int decrypStoreId = 0;

            int.TryParse(DESEncryptTools.DESDecrypt(cookieStoreId), out decrypStoreId);
            return(storeId > 0 && decrypStoreId == storeId);
        }
예제 #20
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));
        }
예제 #21
0
파일: AuthRoleBLL.cs 프로젝트: soon14/vzan
 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);
     }
 }
예제 #22
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);
     }
 }
예제 #23
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);
        }
예제 #24
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 ? "操作成功" : "操作失败"));
        }
예제 #25
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);
     }
 }
예제 #26
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);
        }
예제 #27
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 ? "新增成功" : "新增失败"));
        }
예제 #28
0
        public JsonResult Login(string username, string password, string wxToken = null)
        {
            bool hasInput = !string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password);
            //门店暂时不做微信登陆
            //bool wxLogin = !string.IsNullOrWhiteSpace(wxToken);

            //C_UserInfo userInfo = null;
            DishStore store = null;
            //if (!string.IsNullOrWhiteSpace(wxToken))
            //{
            //    int userId = 0;
            //    int.TryParse(DESEncryptTools.DESEncrypt(wxToken), out userId);
            //    userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);
            //    DishStoreBLL.SingleModel.GetStoreByUserId(userInfo.Id);
            //}

            string loginToken = string.Empty;

            if (store != null)
            {
                loginToken = DESEncryptTools.Encrypt(store.id.ToString());
            }
            else if (hasInput)
            {
                store = DishStoreBLL.SingleModel.GetAdminByLoginParams(username, password);
                if (store == null)
                {
                    return(ApiModel(message: "用户名或密码错误"));
                }
                loginToken = DESEncryptTools.DESEncrypt(store.id.ToString());
            }
            else
            {
                return(ApiModel(message: "用户名和密码不能为空"));
            }

            return(ApiModel(isok: true, message: "登陆成功", data: new { loginToken, storeId = store.id }));
        }
예제 #29
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);
        }
예제 #30
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));
        }