Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(Model.UserMemberInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserMemberInfo(");
            strSql.Append("userId,memCount,isHaveAccountUser,manageMemCount,taskUserWorkYears,busiUserName,tel,address,zipCode,email,fax,instituteDesc,status,remark,addTime,addUser,infoType)");
            strSql.Append(" values (");
            strSql.Append("@userId,@memCount,@isHaveAccountUser,@manageMemCount,@taskUserWorkYears,@busiUserName,@tel,@address,@zipCode,@email,@fax,@instituteDesc,@status,@remark,@addTime,@addUser,@infoType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",            SqlDbType.Int,         4),
                new SqlParameter("@memCount",          SqlDbType.Int,         4),
                new SqlParameter("@isHaveAccountUser", SqlDbType.Int,         4),
                new SqlParameter("@manageMemCount",    SqlDbType.Int,         4),
                new SqlParameter("@taskUserWorkYears", SqlDbType.Int,         4),
                new SqlParameter("@busiUserName",      SqlDbType.VarChar,    50),
                new SqlParameter("@tel",               SqlDbType.VarChar,    50),
                new SqlParameter("@address",           SqlDbType.VarChar,   150),
                new SqlParameter("@zipCode",           SqlDbType.VarChar,    50),
                new SqlParameter("@email",             SqlDbType.VarChar,    50),
                new SqlParameter("@fax",               SqlDbType.VarChar,    50),
                new SqlParameter("@instituteDesc",     SqlDbType.NText),
                new SqlParameter("@status",            SqlDbType.Int,         4),
                new SqlParameter("@remark",            SqlDbType.VarChar,   150),
                new SqlParameter("@addTime",           SqlDbType.DateTime),
                new SqlParameter("@addUser",           SqlDbType.Int,         4),
                new SqlParameter("@infoType",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.userId;
            parameters[1].Value  = model.memCount;
            parameters[2].Value  = model.isHaveAccountUser;
            parameters[3].Value  = model.manageMemCount;
            parameters[4].Value  = model.taskUserWorkYears;
            parameters[5].Value  = model.busiUserName;
            parameters[6].Value  = model.tel;
            parameters[7].Value  = model.address;
            parameters[8].Value  = model.zipCode;
            parameters[9].Value  = model.email;
            parameters[10].Value = model.fax;
            parameters[11].Value = model.instituteDesc;
            parameters[12].Value = model.status;
            parameters[13].Value = model.remark;
            parameters[14].Value = model.addTime;
            parameters[15].Value = model.addUser;
            parameters[16].Value = model.infoType;

            object obj = DBHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.UserMemberInfo GetModelByUserId(int userId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,userId,memCount,isHaveAccountUser,manageMemCount,taskUserWorkYears,busiUserName,tel,address,zipCode,email,fax,instituteDesc,status,remark,addTime,addUser,infoType from UserMemberInfo ");
            strSql.Append(" where userId=@userId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId", SqlDbType.Int, 4)
            };
            parameters[0].Value = userId;

            Model.UserMemberInfo model = new Model.UserMemberInfo();
            DataSet ds = DBHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 处理普通页面请求的情况
        /// </summary>
        /// <param name="filterContext"></param>
        /// <returns>是否中断当前action提前结束</returns>
        bool ProcessInvalidUser_NormalRequest(ActionExecutingContext filterContext)
        {
            bool end = true;
            //处理手动退出后不自动登录
            string actlogout = WebHelper.GetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT);

            //分析当前平台类型,并创建对应的登录接口
            IMobileOAuth imobileOauth = null;

            switch (PlatformType)
            {
            case Core.PlatformType.WeiXin:
                imobileOauth = new WeixinOAuth();
                break;
            }
            string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.ToString()));

            if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口
            {
                //可能的待跳转用户授权地址

                Model.WXShopInfo settings = new Model.WXShopInfo();
                string           redirectUrl;
                //string strShopid = WebHelper.GetCookie(CookieKeysCollection.HIMALL_SHOP);
                //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile");

                string strShopid = filterContext.HttpContext.Request["shop"];
                var    AppidType = Model.MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(strShopid))
                {
                    long shopid = 0;
                    bool isLong = long.TryParse(strShopid, out shopid);
                    if (shopid > 0)
                    {
                        settings = ServiceHelper.Create <IVShopService>().GetVShopSetting(shopid);
                    }
                }

                if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret))
                {
                    settings = new Model.WXShopInfo()
                    {
                        AppId     = CurrentSiteSetting.WeixinAppId,
                        AppSecret = CurrentSiteSetting.WeixinAppSecret,
                        Token     = CurrentSiteSetting.WeixinToken
                    };
                    AppidType = Model.MemberOpenIdInfo.AppIdTypeEnum.Payment;//是平台Appid,可以作为付款(微信支付)
                }

                //获取当前用户信息
                var userInfo = imobileOauth.GetUserInfo(filterContext, out redirectUrl, settings);
                if (string.IsNullOrWhiteSpace(redirectUrl))                              //待跳转地址为空,说明已经经过了用户授权页面
                {
                    if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权
                    {
                        if (AppidType == Model.MemberOpenIdInfo.AppIdTypeEnum.Payment)
                        {
                            var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile");
                            WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER_OpenID, curMenberOpenId);
                        }
                        //检查是否已经有用户绑定过该OpenId
                        //Himall.Core.Log.Debug("InvalidUser LoginProvider=" + userInfo.LoginProvider);
                        //Himall.Core.Log.Debug("InvalidUser OpenId=" + userInfo.OpenId);
                        //Himall.Core.Log.Debug("InvalidUser UnionId=" + userInfo.UnionId);
                        Model.UserMemberInfo existUser = null;
                        //existUser = ServiceHelper.Create<IMemberService>().GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId);
                        if (existUser == null)
                        {
                            if (actlogout != "1")
                            {
                                //existUser = ServiceHelper.Create<IMemberService>().GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId);
                                existUser = ServiceHelper.Create <IMemberService>().GetMemberByUnionId(userInfo.UnionId);
                            }
                        }

                        if (existUser != null)//已经有用户绑定过,直接标识为该用户
                        {
                            base.SetUserLoginCookie(existUser.Id);
                            Application.MemberApplication.UpdateLastLoginDate(existUser.Id);
                        }
                        else//未绑定过,则跳转至登录绑定页面
                        {
                            normalLoginUrl = string.Format("/m-{0}/Login/Entrance?openId={1}&serviceProvider={2}&nickName={3}&realName={4}&headimgurl={5}&returnUrl={6}&AppidType={7}&unionid={8}&sex={9}&city={10}&province={11}&country={12}",
                                                           PlatformType.ToString(),
                                                           userInfo.OpenId,
                                                           "Himall.Plugin.OAuth.WeiXin",//使用同微信登录插件一致的名称, 以此保证微信信任与微信商城登录用户信息统一
                                                           HttpUtility.UrlEncode(userInfo.NickName),
                                                           HttpUtility.UrlEncode(userInfo.RealName),
                                                           HttpUtility.UrlEncode(userInfo.Headimgurl),
                                                           HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.ToString()),
                                                           AppidType,
                                                           userInfo.UnionId,
                                                           userInfo.Sex,
                                                           userInfo.City,
                                                           userInfo.Province,
                                                           userInfo.Country
                                                           );
                            //跳转至登录绑定页面
                            var result = Redirect(normalLoginUrl);
                            filterContext.Result = result;
                        }
                    }
                    else//用户未授权,或者无法获取用户授权
                    {
                        //用户未授权,则跳转至普通登录页面
                        var result = Redirect(normalLoginUrl);
                        filterContext.Result = result;
                    }
                }
                else
                {//立即跳转到用户授权页面
                    var result = Redirect(redirectUrl);
                    filterContext.Result = result;
                }
            }
            else
            {//未找到对应的用户授权实现机制,则跳转至普通登录页面
                var result = Redirect(normalLoginUrl);
                filterContext.Result = result;
            }
            return(end);
        }
        /// <summary>
        /// 为已登录过的用户(存在cookie),绑定OpenId
        /// </summary>
        /// <param name="filterContext"></param>
        /// <returns></returns>
        bool BindOpenIdToUser(ActionExecutingContext filterContext)
        {
            bool end = true;

            //处理手动退出后不自动登录
            string actlogout = WebHelper.GetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT);

            //分析当前平台类型,并创建对应的登录接口
            IMobileOAuth imobileOauth = null;

            switch (PlatformType)
            {
            case Core.PlatformType.WeiXin:
                imobileOauth = new WeixinOAuth();
                break;
            }

            string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.ToString()));

            if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口
            {
                //可能的待跳转用户授权地址
                string redirectUrl;
                //string strShopid = WebHelper.GetCookie(CookieKeysCollection.HIMALL_SHOP);
                //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile");
                Model.WXShopInfo settings  = new Model.WXShopInfo();
                string           strShopid = filterContext.HttpContext.Request["shop"];
                var AppidType = Model.MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(strShopid))
                {
                    Log.Warn(strShopid + ":" + filterContext.HttpContext.Request.Url.ToString());
                    long shopid = 0;
                    bool isLong = long.TryParse(strShopid, out shopid);
                    if (shopid > 0)
                    {
                        settings = ServiceHelper.Create <IVShopService>().GetVShopSetting(shopid);
                    }
                }
                else
                {
                    Log.Warn(filterContext.HttpContext.Request.Url.ToString());
                }

                if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret))
                {
                    settings = new Model.WXShopInfo()
                    {
                        AppId     = CurrentSiteSetting.WeixinAppId,
                        AppSecret = CurrentSiteSetting.WeixinAppSecret,
                        Token     = CurrentSiteSetting.WeixinToken
                    };
                    AppidType = Model.MemberOpenIdInfo.AppIdTypeEnum.Payment;                    //是平台Appid,可以作为付款(微信支付)
                }

                //获取当前用户信息
                var userInfo = imobileOauth.GetUserInfo_bequiet(filterContext, out redirectUrl, settings);

                if (string.IsNullOrWhiteSpace(redirectUrl))                              //待跳转地址为空,说明已经经过了用户授权页面
                {
                    end = false;                                                         //不再中断当前action
                    if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权
                    {
                        if (AppidType == Model.MemberOpenIdInfo.AppIdTypeEnum.Payment)
                        {//记录平台公众号对应的OpenId
                            var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile");
                            WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER_OpenID, curMenberOpenId);
                        }

                        //Himall.Core.Log.Debug("BindOpenIdToUser LoginProvider=" + userInfo.LoginProvider);
                        //Himall.Core.Log.Debug("BindOpenIdToUser OpenId=" + userInfo.OpenId);
                        //Himall.Core.Log.Debug("BindOpenIdToUser UnionId=" + userInfo.UnionId);
                        //检查是否已经有用户绑定过该OpenId
                        IMemberService       member    = ServiceHelper.Create <IMemberService>();
                        Model.UserMemberInfo existUser = null;
                        //existUser = member.GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId);
                        if (existUser == null)
                        {
                            if (actlogout != "1")
                            {
                                //existUser = member.GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId);
                                existUser = member.GetMemberByUnionId(userInfo.UnionId);
                            }
                        }
                        if (existUser != null)
                        {
                            if (!string.IsNullOrEmpty(strShopid))
                            {
                                base.SetUserLoginCookie(existUser.Id);
                                Application.MemberApplication.UpdateLastLoginDate(existUser.Id);
                            }
                        }
                        else                        //未绑定过,则绑定当前用户
                        {
                            member.BindMember(CurrentUser.Id, "Himall.Plugin.OAuth.WeiXin", userInfo.OpenId, AppidType, userInfo.Sex, userInfo.Headimgurl, unionid: userInfo.UnionId);
                            //end = false;//不再中断当前action
                        }
                    }
                }
                else
                {//立即跳转到用户授权页面
                    var result = Redirect(redirectUrl);
                    filterContext.Result = result;
                }
            }
            else
            {
                end = false;
            }
            return(end);
        }
Пример #5
0
        /// <summary>
        /// 修改所有信息时更新我的主页顶部信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int UpdateModAll(Model.UserMemberInfo model)
        {
            string sql = "update UserMemberInfo set busiUserName = '******',tel = '" + model.tel + "',zipCode = '" + model.zipCode + "',address = '" + model.address + "' where userId = " + model.userId;

            return(DBHelperSQL.ExecuteSql(sql));
        }
Пример #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static Model.UserMemberInfo DataRowToModel(DataRow row)
 {
     Model.UserMemberInfo model = new Model.UserMemberInfo();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["userId"] != null && row["userId"].ToString() != "")
         {
             model.userId = int.Parse(row["userId"].ToString());
         }
         if (row["memCount"] != null && row["memCount"].ToString() != "")
         {
             model.memCount = int.Parse(row["memCount"].ToString());
         }
         if (row["isHaveAccountUser"] != null && row["isHaveAccountUser"].ToString() != "")
         {
             model.isHaveAccountUser = int.Parse(row["isHaveAccountUser"].ToString());
         }
         if (row["manageMemCount"] != null && row["manageMemCount"].ToString() != "")
         {
             model.manageMemCount = int.Parse(row["manageMemCount"].ToString());
         }
         if (row["taskUserWorkYears"] != null && row["taskUserWorkYears"].ToString() != "")
         {
             model.taskUserWorkYears = int.Parse(row["taskUserWorkYears"].ToString());
         }
         if (row["busiUserName"] != null)
         {
             model.busiUserName = row["busiUserName"].ToString();
         }
         if (row["tel"] != null)
         {
             model.tel = row["tel"].ToString();
         }
         if (row["address"] != null)
         {
             model.address = row["address"].ToString();
         }
         if (row["zipCode"] != null)
         {
             model.zipCode = row["zipCode"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["fax"] != null)
         {
             model.fax = row["fax"].ToString();
         }
         if (row["instituteDesc"] != null)
         {
             model.instituteDesc = row["instituteDesc"].ToString();
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["addTime"] != null && row["addTime"].ToString() != "")
         {
             model.addTime = DateTime.Parse(row["addTime"].ToString());
         }
         if (row["addUser"] != null && row["addUser"].ToString() != "")
         {
             model.addUser = int.Parse(row["addUser"].ToString());
         }
         if (row["infoType"] != null && row["infoType"].ToString() != "")
         {
             model.infoType = int.Parse(row["infoType"].ToString());
         }
     }
     return(model);
 }
Пример #7
0
        /// <summary>
        ///修改所有信息时更新机构运营状况信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int UpdateModALl2(Model.UserMemberInfo model)
        {
            string sql = "update UserMemberInfo set manageMemCount = " + model.manageMemCount + ",taskUserWorkYears = " + model.taskUserWorkYears + ",busiUserName = '******',tel = '" + model.tel + "',address = '" + model.address + "',zipCode = '" + model.zipCode + "',email = '" + model.email + "',fax = '" + model.fax + "' where userId = " + model.userId;

            return(DBHelperSQL.ExecuteSql(sql));
        }
Пример #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static int Update(Model.UserMemberInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserMemberInfo set ");
            strSql.Append("userId=@userId,");
            strSql.Append("memCount=@memCount,");
            strSql.Append("isHaveAccountUser=@isHaveAccountUser,");
            strSql.Append("manageMemCount=@manageMemCount,");
            strSql.Append("taskUserWorkYears=@taskUserWorkYears,");
            strSql.Append("busiUserName=@busiUserName,");
            strSql.Append("tel=@tel,");
            strSql.Append("address=@address,");
            strSql.Append("zipCode=@zipCode,");
            strSql.Append("email=@email,");
            strSql.Append("fax=@fax,");
            strSql.Append("instituteDesc=@instituteDesc,");
            strSql.Append("status=@status,");
            strSql.Append("remark=@remark,");
            strSql.Append("addTime=@addTime,");
            strSql.Append("addUser=@addUser,");
            strSql.Append("infoType=@infoType");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",            SqlDbType.Int,         4),
                new SqlParameter("@memCount",          SqlDbType.Int,         4),
                new SqlParameter("@isHaveAccountUser", SqlDbType.Int,         4),
                new SqlParameter("@manageMemCount",    SqlDbType.Int,         4),
                new SqlParameter("@taskUserWorkYears", SqlDbType.Int,         4),
                new SqlParameter("@busiUserName",      SqlDbType.VarChar,    50),
                new SqlParameter("@tel",               SqlDbType.VarChar,    50),
                new SqlParameter("@address",           SqlDbType.VarChar,   150),
                new SqlParameter("@zipCode",           SqlDbType.VarChar,    50),
                new SqlParameter("@email",             SqlDbType.VarChar,    50),
                new SqlParameter("@fax",               SqlDbType.VarChar,    50),
                new SqlParameter("@instituteDesc",     SqlDbType.NText),
                new SqlParameter("@status",            SqlDbType.Int,         4),
                new SqlParameter("@remark",            SqlDbType.VarChar,   150),
                new SqlParameter("@addTime",           SqlDbType.DateTime),
                new SqlParameter("@addUser",           SqlDbType.Int,         4),
                new SqlParameter("@infoType",          SqlDbType.Int,         4),
                new SqlParameter("@id",                SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.userId;
            parameters[1].Value  = model.memCount;
            parameters[2].Value  = model.isHaveAccountUser;
            parameters[3].Value  = model.manageMemCount;
            parameters[4].Value  = model.taskUserWorkYears;
            parameters[5].Value  = model.busiUserName;
            parameters[6].Value  = model.tel;
            parameters[7].Value  = model.address;
            parameters[8].Value  = model.zipCode;
            parameters[9].Value  = model.email;
            parameters[10].Value = model.fax;
            parameters[11].Value = model.instituteDesc;
            parameters[12].Value = model.status;
            parameters[13].Value = model.remark;
            parameters[14].Value = model.addTime;
            parameters[15].Value = model.addUser;
            parameters[16].Value = model.infoType;
            parameters[17].Value = model.id;

            int rows = DBHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            return(rows);
        }