Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            userlevelid = RequestTool.RequestInt("userlevelid");
            userid      = RequestTool.RequestInt("userid");
            typeid      = RequestTool.RequestInt("typeid");
            showall     = RequestTool.RequestInt("showall");
            key         = RequestTool.RequestString("key");
            user        = B_Lebi_User.GetModel(userid);
            userlevel   = B_Lebi_UserLevel.GetModel(userlevelid);
            if (user == null)
            {
                user = new Lebi_User();
            }
            if (userlevel == null)
            {
                userlevel = new Lebi_UserLevel();
            }
            string where = "Product_id=0 and (IsDel!=1 or IsDel is null)";
            if (key != "")
            {
                where += " and (Name like '%" + key + "%' or Number like '%" + key + "%' or Code like '%" + key + "%')";
            }
            if (typeid > 0)
            {
                string tids = EX_Product.TypeIds(typeid);
                where += " and Pro_Type_id in (" + tids + ")";
            }

            PageSize = RequestTool.getpageSize(10);
            int recordCount = B_Lebi_Product.Counts(where);

            PageString = Pager.GetPaginationStringForJS("reloadproducts({0}," + typeid + ",'" + key + "'," + user.id + "," + userlevel.id + ");", page, PageSize, recordCount);
            products   = B_Lebi_Product.GetList(where, "", PageSize, page);
        }
Пример #2
0
 protected ShopControl()
 {
     SYS = ShopCache.GetBaseConfig();
     //CurrentLanguage_ = B_Lebi_Language.GetList("Code='CN'", "").FirstOrDefault();
     //CurrentTheme_ = new Lebi_Theme();
     CurrentUser      = EX_User.CurrentUser();
     CurrentUserLevel = B_Lebi_UserLevel.GetModel("id=" + CurrentUser.UserLevel_id + "");
     if (CurrentUserLevel == null)
     {
         CurrentUserLevel = B_Lebi_UserLevel.GetList("", "Grade desc").FirstOrDefault();
         if (CurrentUserLevel == null)
         {
             CurrentUserLevel = new Lebi_UserLevel();
             Log.Add("会员分组有误", "User_id=" + CurrentUser.id.ToString());
         }
     }
     WebPath = RequestTool.GetConfigKey("WebPath");
     WebPath = WebPath == "/" ? "" : WebPath;
     if (WebPath != "")
     {
         int h = WebPath.Length;
         if (WebPath.LastIndexOf("/") == h - 1)
         {
             WebPath = WebPath.Remove(h - 1);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// 更新会员积分
        /// </summary>
        /// <param name="user"></param>
        public static void UpdateUserPoint(Lebi_User user)
        {
            string  point = B_Lebi_User_Point.GetValue("sum(Point)", "User_id=" + user.id + " and Type_id_PointStatus=171");
            decimal Point = 0;

            Decimal.TryParse(point, out Point);
            Lebi_UserLevel userlev = B_Lebi_UserLevel.GetModel(user.UserLevel_id);

            if (userlev == null)
            {
                userlev = new Lebi_UserLevel();
            }
            List <Lebi_UserLevel> ls = B_Lebi_UserLevel.GetList("Grade > " + userlev.Grade + "", "Grade desc");

            //Lebi_UserLevel newlev=new Lebi_UserLevel();
            if (ls.Count > 0)
            {
                foreach (Lebi_UserLevel l in ls)
                {
                    if (Point >= l.Lpoint)
                    {
                        user.UserLevel_id = l.id;
                        //newlev = l;
                        break;
                    }
                }
            }
            //if (userlev.Grade < newlev.Grade)
            //{
            user.Point = Point;
            B_Lebi_User.Update(user);
            //}
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            userlevelid = RequestTool.RequestInt("userlevelid");
            userid      = RequestTool.RequestInt("userid");
            orderid     = RequestTool.RequestInt("orderid");
            typeid      = RequestTool.RequestInt("typeid");
            key         = RequestTool.RequestString("key");

            user      = B_Lebi_User.GetModel(userid);
            userlevel = B_Lebi_UserLevel.GetModel(userlevelid);
            if (user == null)
            {
                user = new Lebi_User();
            }
            if (userlevel == null)
            {
                userlevel = new Lebi_UserLevel();
            }


            string where = "Product_id=0";
            if (key != "")
            {
                where += " and (Name like '%" + key + "%' or Number like '%" + key + "%' or Code like '%" + key + "%')";
            }
            if (typeid > 0)
            {
                string tids = EX_Product.TypeIds(typeid);
                where += " and Pro_Type_id in (" + tids + ")";
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PageSize    = RequestTool.getpageSize(25);
            proid       = RequestTool.RequestInt("proid");
            userlevelid = RequestTool.RequestInt("userlevelid");

            string where = "User_id=0";
            if (proid > 0)
            {
                where += " and Product_id=" + proid;
            }
            if (userlevelid > 0)
            {
                where += " and UserLevel_id=" + userlevelid;
            }
            models = B_Lebi_Product_Limit.GetList(where, "", PageSize, page);

            int recordCount = B_Lebi_Product_Limit.Counts(where);

            PageString = Pager.GetPaginationString("?page={0}&userlevelid=" + userlevelid + "&proid=" + proid, page, PageSize, recordCount);
            cuser      = GetUserLevel(userlevelid);
            cproduct   = GetPro(proid);
            if (cuser.id > 0)
            {
                ename = Lang(cuser.Name);
            }
            if (cproduct.id > 0)
            {
                ename = Lang(cproduct.Name);
            }
        }
Пример #6
0
        public string GetlevelName(int id)
        {
            Lebi_UserLevel model = B_Lebi_UserLevel.GetModel(id);

            if (model == null)
            {
                return("");
            }
            return(Lang(model.Name));
        }
Пример #7
0
        public Lebi_UserLevel GetUserLevel(int id)
        {
            Lebi_UserLevel pro = B_Lebi_UserLevel.GetModel(id);

            if (pro == null)
            {
                return(new Lebi_UserLevel());
            }
            return(pro);
        }
Пример #8
0
        private decimal GetAngentCommission3(Lebi_DT_Agent dt_agent, Lebi_User user)
        {
            if (user != null)
            {
                Lebi_UserLevel userlevel = B_Lebi_UserLevel.GetModel(user.UserLevel_id);
                if (userlevel != null)
                {
                    if (userlevel.IsUsedAgent == 0) //关闭推广佣金
                    {
                        return(0);
                    }
                }
                if (dt_agent != null)
                {
                    if (dt_agent.IsUsedAgent == 0)
                    {
                        return(0);
                    }
                    if (dt_agent.Angent3_Commission != -1)
                    {
                        return(dt_agent.Angent3_Commission);
                    }
                }
                Lebi_Agent_User agent_user = B_Lebi_Agent_User.GetModel("User_id = " + user.id + "");
                if (agent_user != null)
                {
                    if (agent_user.Angent3_Commission != -1)
                    {
                        return(agent_user.Angent3_Commission);
                    }
                }
                Lebi_Agent_UserLevel agent_userlevel = B_Lebi_Agent_UserLevel.GetModel("UserLevel_id = " + user.UserLevel_id + "");
                if (agent_userlevel != null)
                {
                    if (agent_userlevel.Angent3_Commission != -1)
                    {
                        return(agent_userlevel.Angent3_Commission);
                    }
                }
            }
            decimal yongjin = 0;//3级佣金比例

            decimal.TryParse(bc.Angent3_Commission, out yongjin);
            return(yongjin);
        }
Пример #9
0
        /// <summary>
        /// 删除会员分组
        /// </summary>
        public void UserLevel_Del()
        {
            int id = RequestTool.RequestInt("id", 0);

            if (!EX_Admin.Power("userlevel_del", "删除会员分组"))
            {
                AjaxNoPower();
                return;
            }
            //Lebi_Page model = B_Lebi_Page.GetModel(id);
            // if (model == null)
            //{
            //    Response.Write("{\"msg\":\"" + Tag("参数错误") +"\"}");
            //    return;
            //}
            //<-{删除会员分组,等级更新为上一等级 by kingdge
            int            UserLevel_id = 1;
            Lebi_UserLevel model        = B_Lebi_UserLevel.GetModel(id);

            if (model == null)
            {
                UserLevel_id = 1;
            }
            else
            {
                UserLevel_id = model.id;
            }
            Common.ExecuteSql("Update Lebi_User set UserLevel_id = " + UserLevel_id + " where UserLevel_id = " + id + "");
            //}->
            List <Lebi_UserLevel> ls = B_Lebi_UserLevel.GetList("id in (lbsql{" + id + "})", "");

            foreach (var l in ls)
            {
                int count = B_Lebi_User.Counts("(IsDel!=1 or IsDel is null) and UserLevel_id=" + l.id + "");
                if (count > 0)
                {
                    Response.Write("{\"msg\":\"分组下存在账号,不能删除\"}");
                    return;
                }
            }
            B_Lebi_UserLevel.Delete("id in (lbsql{" + id + "})");
            Log.Add("删除会员分组", "UserLevel", id.ToString(), CurrentAdmin, id.ToString());
            Response.Write("{\"msg\":\"OK\"}");
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("product_user_price", "商品会员价格"))
            {
                WindowNoPower();
            }
            userlevelid = RequestTool.RequestInt("userlevelid");
            userid      = RequestTool.RequestInt("userid");
            productid   = RequestTool.RequestInt("productid");
            key         = RequestTool.RequestString("key");
            userlevel   = B_Lebi_UserLevel.GetModel(userlevelid);
            product     = B_Lebi_Product.GetModel(productid);
            if (product == null)
            {
                product = new Lebi_Product();
            }
            if (userlevel == null)
            {
                userlevel = new Lebi_UserLevel();
            }
            string where = "IsAnonymous<>1";
            if (key != "")
            {
                where += " and (UserName like '%" + key + "%' or RealName like '%" + key + "%' or NickName like '%" + key + "%')";
            }
            if (userlevelid > 0)
            {
                where += " and UserLevel_id =" + userlevelid + "";
            }
            PageSize = RequestTool.getpageSize(10);
            int recordCount = B_Lebi_User.Counts(where);

            PageString = Pager.GetPaginationStringForJS("reloadproducts({0},'" + key + "'," + userlevel.id + ");", page, PageSize, recordCount);
            users      = B_Lebi_User.GetList(where, "", PageSize, page);

            userlevellimit = B_Lebi_Product_Price.GetModel("Product_id=" + product.id + "");
            if (userlevellimit == null)
            {
                userlevellimit = new Lebi_Product_Price();
            }
        }
Пример #11
0
        public ShopPage()
        {
            pageindex = RequestTool.RequestInt("pageindex", 0);
            string servicepannelcon = SYS.ServicePanel;

            servicepannel     = B_ServicePanel.GetModel(servicepannelcon);
            CurrentUser_      = EX_User.CurrentUser();
            CurrentUserLevel_ = B_Lebi_UserLevel.GetModel("id=" + CurrentUser_.UserLevel_id + "");

            if (CurrentUserLevel_ == null)
            {
                CurrentUserLevel_ = B_Lebi_UserLevel.GetList("Grade=0", "Grade asc").FirstOrDefault();
                if (CurrentUserLevel_ == null)
                {
                    CurrentUserLevel_ = new Lebi_UserLevel();
                    Log.Add("会员分组有误", "User_id=" + CurrentUser_.id.ToString());
                }
            }
            DT_id     = GetDT();
            Currencys = B_Lebi_Currency.GetList("1=1", "Sort desc");
        }
Пример #12
0
        /// <summary>
        /// 编辑会员分组
        /// </summary>
        public void UserLevel_Edit()
        {
            int            id    = RequestTool.RequestInt("id", 0);
            Lebi_UserLevel model = B_Lebi_UserLevel.GetModel(id);

            if (model == null)
            {
                model = new Lebi_UserLevel();
            }
            B_Lebi_UserLevel.SafeBindForm(model);
            model.Name      = Language.RequestString("Name");
            model.PriceName = Language.RequestString("PriceName");
            if (model.id == 0)
            {
                if (!EX_Admin.Power("userlevel_add", "添加会员分组"))
                {
                    AjaxNoPower();
                    return;
                }
                B_Lebi_UserLevel.Add(model);
                id = B_Lebi_UserLevel.GetMaxId();
                Log.Add("添加会员分组", "UserLevel", id.ToString(), CurrentAdmin, Shop.Bussiness.Language.Content(Language.RequestString("Name"), "CN"));
            }
            else
            {
                if (!EX_Admin.Power("userlevel_edit", "编辑会员分组"))
                {
                    AjaxNoPower();
                    return;
                }
                B_Lebi_UserLevel.Update(model);
                Log.Add("编辑会员分组", "UserLevel", id.ToString(), CurrentAdmin, Shop.Bussiness.Language.Content(Language.RequestString("Name"), "CN"));
            }
            ImageHelper.LebiImagesUsed(model.ImageUrl, "config", id);
            string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}";

            Response.Write(result);
        }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = RequestTool.RequestInt("id", 0);

            if (id == 0)
            {
                if (!EX_Admin.Power("userlevel_add", "添加会员分组"))
                {
                    PageNoPower();
                }
            }
            else
            {
                if (!EX_Admin.Power("userlevel_edit", "编辑会员分组"))
                {
                    PageNoPower();
                }
            }
            model = B_Lebi_UserLevel.GetModel(id);
            if (model == null)
            {
                model = new Lebi_UserLevel();
            }
        }
Пример #14
0
        public string Login(string back, int IsLogin = 1)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + ENBackuri(back);
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    string res = PostAPI("oauth2/access_token", sb.ToString());

                    JavaScriptSerializer jss   = new JavaScriptSerializer();
                    Model.Weibo.token    token = jss.Deserialize <Model.Weibo.token>(res);
                    string access_token        = token.access_token;
                    //获取uid
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    res = PostAPI("oauth2/get_token_info", sb.ToString());
                    Model.Weibo.tokeninfo tokeninfo = jss.Deserialize <Model.Weibo.tokeninfo>(res);
                    string uid = tokeninfo.uid;

                    //获取用户资料
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    sb.Append("&uid=" + uid);

                    res = GetAPI("2/users/show.json", sb.ToString());


                    Model.Weibo.userinfo model = jss.Deserialize <Model.Weibo.userinfo>(res);
                    string where = "bind_weibo_id='" + uid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = EX_User.CurrentUser();
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_weibo_id       = uid;
                        CurrentUser.bind_weibo_nickname = model.screen_name;
                        CurrentUser.bind_weibo_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.profile_image_url;//头像 50*50
                        }
                        CurrentUser.DT_id = DT_id;
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user = new Lebi_User();
                            user.bind_weibo_id       = uid;
                            user.bind_weibo_nickname = model.screen_name;
                            user.bind_weibo_token    = access_token;
                            user.Face              = model.profile_image_url;//头像 50*50
                            user.NickName          = model.screen_name;
                            user.UserName          = "******" + uid;
                            user.Password          = EX_User.MD5(uid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.gender == "f" ? "女" : "男";
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            user.DT_id = DT_id;
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_weibo_id       = uid;
                            user.bind_weibo_nickname = model.screen_name;
                            user.bind_weibo_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.profile_image_url;//头像
                            }
                            //user.Sex = model.gender == "f" ? "女" : "男";
                            user.DT_id = DT_id;
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Пример #15
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_UserLevel model)
 {
     return(D_Lebi_UserLevel.Instance.Add(model));
 }
Пример #16
0
        public string Login(string back, int IsLogin = 1, int DT_id = 0)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + back;
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    string res = API("oauth2.0/token", sb.ToString());
                    res = res + "&";
                    string access_token = RegexTool.GetRegValue(res, "access_token=(.*?)&");

                    //获取openid
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    res = API("oauth2.0/me", sb.ToString());
                    string openid = RegexTool.GetRegValue(res, "openid\":\"(.*?)\"}");

                    //获取用户资料
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    sb.Append("&oauth_consumer_key=" + appid);
                    sb.Append("&openid=" + openid);
                    res = API("user/get_user_info", sb.ToString());

                    JavaScriptSerializer jss   = new JavaScriptSerializer();
                    Model.QQ.userinfo    model = jss.Deserialize <Model.QQ.userinfo>(res);
                    string where = "bind_qq_id='" + openid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User CurrentUser = EX_User.CurrentUser();
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_qq_id       = openid;
                        CurrentUser.bind_qq_nickname = model.nickname;
                        CurrentUser.bind_qq_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.figureurl_qq_1;//头像
                        }
                        CurrentUser.DT_id = DT_id;
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user                   = new Lebi_User();
                            user.bind_qq_id        = openid;
                            user.bind_qq_nickname  = model.nickname;
                            user.bind_qq_token     = access_token;
                            user.Face              = model.figureurl_qq_1;//头像
                            user.UserName          = "******" + openid;
                            user.NickName          = model.nickname;
                            user.Password          = EX_User.MD5(openid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.gender;
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            user.DT_id = DT_id;
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_qq_id       = openid;
                            user.bind_qq_nickname = model.nickname;
                            user.bind_qq_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.figureurl_qq_1;//头像
                            }
                            //user.Sex = model.gender;
                            user.DT_id = DT_id;
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Пример #17
0
        /// <summary>
        /// 用户注册
        /// </summary>
        public void User_Reg()
        {
            string url = "";
            bool   Checkmobilephone = false;
            bool   Checkemail       = false;
            string MobilePhone      = RequestTool.RequestSafeString("MobilePhone");
            string Email            = RequestTool.RequestSafeString("Email");

            try
            {
                Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                if (defaultlevel == null)
                {
                    defaultlevel = new Lebi_UserLevel();
                }
                if (defaultlevel.RegisterType == 0) //关闭注册
                {
                    Response.Write("{\"msg\":\"" + Tag("会员注册已关闭") + "\"}");
                    return;
                }
                if (SYS.UserRegCheckedType.Contains("mobilephone"))
                {
                    Checkmobilephone = true;
                    string MobilePhone_checkcode = RequestTool.RequestSafeString("MobilePhone_checkcode");
                    try
                    {
                        string phonecheckcode = (string)Session["phonecheckcode"];//phonecheckcode
                        if (phonecheckcode != (MobilePhone + MobilePhone_checkcode))
                        {
                            Response.Write("{\"msg\":\"" + Tag("手机验证码错误") + phonecheckcode + "(" + MobilePhone + MobilePhone_checkcode + ")\"}");
                            return;
                        }
                        if (SYS.IsMobilePhoneMutiReg == "0")
                        {
                            int phonecount = B_Lebi_User.Counts("MobilePhone=lbsql{'" + MobilePhone + "'} and IsCheckedMobilePhone=1");
                            if (phonecount > 0)
                            {
                                Response.Write("{\"msg\":\"" + Tag("此手机号已经注册") + "\"}");
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write("{\"msg\":\"" + Tag("手机验证码错误") + "" + ex.ToString() + "\"}");
                        return;
                    }
                }
                if (SYS.UserRegCheckedType.Contains("email"))
                {
                    Checkemail = true;
                    string Email_checkcode = RequestTool.RequestSafeString("Email_checkcode");
                    try
                    {
                        string emailcheckcode = (string)Session["emailcheckcode"];
                        if (emailcheckcode != (Email + Email_checkcode))
                        {
                            Response.Write("{\"msg\":\"" + Tag("邮件验证码错误") + "\"}");
                            return;
                        }
                        int emailcount = B_Lebi_User.Counts("Email=lbsql{'" + Email + "'} and IsCheckedEmail=1");
                        if (emailcount > 0)
                        {
                            Response.Write("{\"msg\":\"" + Tag("此邮箱已经注册") + "\"}");
                            return;
                        }
                    }
                    catch
                    {
                        Response.Write("{\"msg\":\"" + Tag("邮件验证码错误") + "\"}");
                        return;
                    }
                }
                if (SYS.Verifycode_UserRegister == "1")
                {
                    if (Checkemail == false && Checkmobilephone == false)
                    {
                        string verifycode = RequestTool.RequestString("verifycode");
                        if (CurrentCheckCode != verifycode)
                        {
                            Response.Write("{\"msg\":\"" + Tag("验证码错误") + "\"}");
                            return;
                        }
                    }
                }
                string UserName = RequestTool.RequestSafeString("UserName");
                string PWD      = RequestTool.RequestSafeString("Password");
                string token    = RequestTool.RequestString("token");
                if (UserName == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("请输入用户名") + "\"}");
                    return;
                }
                if (PWD == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("请输入密码") + "\"}");
                    return;
                }
                //检查用户名存在
                int count = B_Lebi_User.Counts("UserName=lbsql{'" + UserName + "'}");
                if (count > 0)
                {
                    Response.Write("{\"msg\":\"" + Tag("用户名已注册") + "\"}");
                    return;
                }
                var nv           = CookieTool.GetCookie("parentuser");
                int parentuserid = 0;
                if (!string.IsNullOrEmpty(nv.Get("id")))
                {
                    string parentuserid_ = nv.Get("id");
                    int.TryParse(parentuserid_, out parentuserid);
                }
                if (parentuserid == 0)
                {
                    parentuserid = RequestTool.RequestInt("parentuserid", 0);
                }
                if (parentuserid != 0)
                {
                    Lebi_User puser = B_Lebi_User.GetModel("id=" + parentuserid + "");
                    if (puser != null)
                    {
                        if (defaultlevel.RegisterType == 2)  //邀请注册
                        {
                            Lebi_UserLevel userlevel = B_Lebi_UserLevel.GetModel(puser.UserLevel_id);
                            if (userlevel != null)
                            {
                                if (userlevel.RegisterType == 0) //关闭注册
                                {
                                    Response.Write("{\"msg\":\"" + Tag("会员注册已关闭") + "\"}");
                                    return;
                                }
                            }
                        }
                        if (SYS.IsUsedAgent == "1")
                        {
                            if (Shop.LebiAPI.Service.Instanse.Check("plugin_agent"))
                            {
                                parentuserid = puser.id;
                                puser.Count_sonuser++;
                                B_Lebi_User.Update(puser);
                            }
                        }
                    }
                }
                else
                {
                    if (defaultlevel.RegisterType == 2)  //邀请注册
                    {
                        Response.Write("{\"msg\":\"" + Tag("请输入邀请码") + "\"}");
                        return;
                    }
                }
                Lebi_User model = new Lebi_User();
                B_Lebi_User.SafeBindForm(model);
                model.NickName     = model.UserName;
                model.Password     = EX_User.MD5(PWD);
                model.UserLevel_id = defaultlevel.id;
                model.Time_Reg     = DateTime.Now;
                model.Time_This    = DateTime.Now;
                model.Time_Last    = DateTime.Now;
                model.Count_Login  = 1;
                model.IP_This      = RequestTool.GetClientIP();
                model.IP_Last      = RequestTool.GetClientIP();
                if (Checkemail)
                {
                    model.IsCheckedEmail = 1;
                }
                if (Checkmobilephone)
                {
                    model.IsCheckedMobilePhone = 1;
                }
                model.User_id_parent = parentuserid;
                if (CurrentSite != null)
                {
                    model.Site_id = CurrentSite.id;
                }
                if (CurrentLanguage != null)
                {
                    model.Language = CurrentLanguage.Code;
                }
                model.Area_id = RequestTool.RequestInt("Area_id", 0);
                int DefaultUserEndDays = 0;
                int.TryParse(SYS.DefaultUserEndDays, out DefaultUserEndDays);
                model.Time_End = System.DateTime.Now.AddDays(DefaultUserEndDays);
                Lebi_User user = EX_User.UserReg(model, PWD);
                try
                {
                    //发送邮件
                    if (ShopCache.GetBaseConfig().MailSign.ToLower().Contains("zhuce") || ShopCache.GetBaseConfig().AdminMailSign.ToLower().Contains("register"))
                    {
                        Shop.Bussiness.Email.SendEmail_newuser(user);
                    }
                    //发送短信
                    if (ShopCache.GetBaseConfig().SMS_sendmode.Contains("SMSTPL_newuser") || ShopCache.GetBaseConfig().SMS_sendmode.Contains("SMSTPL_Admin_newuser"))
                    {
                        SMS.SendSMS_newuser(user);
                    }
                }
                catch { }
                url = RequestTool.RequestString("url").Replace("<", "").Replace(">", "");
                if (EX_User.MD5(SYS.InstallCode + url) != token)
                {
                    url = URL("P_Index", "");
                }
                if (url.ToLower().IndexOf("http") > -1 || url.ToLower().IndexOf(URL("P_Register", "").ToLower()) > -1 || url.ToLower().IndexOf(URL("P_Login", "").ToLower()) > -1 || url == "")
                {
                    url = URL("P_Index", "");
                }
                Response.Write("{\"msg\":\"OK\",\"url\":\"" + url + "\"}");
            }
            catch (Exception e)
            {
                SystemLog.Add("User_Reg-" + e.ToString());
            }
        }
Пример #18
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_UserLevel model)
 {
     D_Lebi_UserLevel.Instance.Update(model);
 }
Пример #19
0
        public string Login(string back, int IsLogin = 1, int DT_id = 0)
        {
            string        code = RequestTool.RequestString("code");
            string        res  = "";
            StringBuilder sb;

            if (code != "")
            {
                try
                {
                    sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + ENBackuri(back);
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    res = PostAPI("oauth/access_token", sb.ToString());
                    res = res + "&";
                    string access_token      = RegexTool.GetRegValue(res, "access_token=(.*?)&");
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    //获取uid
                    sb = new StringBuilder();
                    sb.Append("?access_token=" + access_token);
                    res = GetAPI("me", sb.ToString());
                    Model.Facebook.userinfo model = jss.Deserialize <Model.Facebook.userinfo>(res);
                    string uid = model.id;
                    //return uid;
                    string where = "bind_facebook_id='" + uid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Shop.Model.Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User            CurrentUser = EX_User.CurrentUser();
                    if (model == null)
                    {
                        model = new Model.Facebook.userinfo();
                    }
                    if (model.picture == null)
                    {
                        model.picture = new Model.Facebook.userinfo.picture_();
                    }
                    if (model.picture.data == null)
                    {
                        model.picture.data     = new Model.Facebook.userinfo.picture_.data_();
                        model.picture.data.url = "";
                    }
                    string username = model.last_name + model.first_name;
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_facebook_id       = uid;
                        CurrentUser.bind_facebook_nickname = username;
                        CurrentUser.bind_facebook_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.picture.data.url;//头像
                        }
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user = new Lebi_User();
                            user.bind_facebook_id       = uid;
                            user.bind_facebook_nickname = username;
                            user.bind_facebook_token    = access_token;
                            user.Face              = model.picture.data.url;
                            user.NickName          = username;
                            user.UserName          = "******" + uid;
                            user.Password          = EX_User.MD5(uid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.gender == "female" ? "女" : "男";
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_facebook_id       = uid;
                            user.bind_facebook_nickname = username;
                            user.bind_facebook_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.picture.data.url;
                            }
                            //user.Sex = model.gender == "female" ? "女" : "男";
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Пример #20
0
        /// <summary>
        /// 计算促销活动
        /// </summary>
        /// <param name="Products">商品信息</param>
        /// <param name="CurrentUser">购买者</param>
        /// <param name="shop">供应商,为空表示自营商品</param>
        /// <param name="basketshop"></param>
        public static BasketShop SetMoneyAndPoint(Lebi_User CurrentUser, Lebi_UserLevel CurrentUserLevel, BasketShop basketshop)
        {
            string  pids = "0";
            decimal Money_Product_begin = 0;
            int     Count  = 0;
            decimal Weight = 0; //订单总重量
            decimal Volume = 0; //订单总体积

            int     Money_Transport_One = 0;
            bool    IsTransportPriceOne = false;
            decimal Money_Market        = 0;
            decimal Money_Cut           = 0;
            decimal Money_Give          = 0;
            decimal Point_Free          = 0; //赠送积分
            decimal Point_Product       = 0; //商品获得的积分
            decimal Point          = 0;      //获得的积分总数
            decimal Point_Buy      = 0;      //积分换购所需积分
            decimal Money_Product  = 0;
            decimal Money_Property = 0;
            List <Lebi_User_Product>   FreeProducts   = new List <Lebi_User_Product>();
            List <Lebi_Promotion_Type> PromotionTypes = new List <Lebi_Promotion_Type>();

            if (CurrentUserLevel == null)
            {
                CurrentUserLevel = B_Lebi_UserLevel.GetModel(CurrentUser.UserLevel_id);
            }
            List <Lebi_User_Product> Products = basketshop.Products;
            Lebi_Supplier            shop     = basketshop.Shop;

            foreach (Lebi_User_Product pro in Products)
            {
                Lebi_Product product = B_Lebi_Product.GetModel(pro.Product_id);
                if (product == null)
                {
                    continue;
                }
                pro.Discount   = 100;
                pro.Pointagain = 1;
                //pro.Product_Price = EX_Product.ProductPrice(product, CurrentUserLevel,pro.count);//单价
                if (CurrentUserLevel.MoneyToPoint > 0)
                {
                    pro.Product_Point = pro.Product_Price * CurrentUserLevel.MoneyToPoint + pro.Product_Point;//单个产品可得的积分
                }
                pids += "," + pro.Product_id;
                Money_Product_begin = Math.Round(Money_Product_begin + pro.Product_Price * pro.count, 2);
                Count          = Count + pro.count;
                Money_Market   = Money_Market + EX_Product.ProductMarketPrice(product) * pro.count; //兼容分销  2018.3.8 by lebi.kingdge
                Money_Property = Money_Property + pro.ProPerty_Price * pro.count;
                Money_Product  = Money_Product + pro.Product_Price * pro.count;
                Weight         = Weight + product.Weight * pro.count;
                Volume         = Volume + product.VolumeH * product.VolumeL * product.VolumeW * pro.count;
                Point_Product  = Point_Product + Math.Round(pro.Product_Point * pro.count, 2);
                Point          = Point_Product + Point_Free;
                //320一般商品321限时抢购322团购323积分换购
                if (product.Type_id_ProductType == 323 && product.Time_Expired > System.DateTime.Now)
                {
                    Point_Buy = Point_Buy + product.Price_Sale * pro.count;
                }
            }

            List <Lebi_Promotion_Type> cps = Promotion.CurrentPromotionType();

            if (shop == null)
            {
                shop = new Lebi_Supplier();
            }
            foreach (Lebi_Promotion_Type cp in cps)
            {
                //检查是否商铺单独促销
                if (cp.Type_id_PromotionType == 421)
                {
                    if (shop.id > 0)
                    {
                        continue;
                    }
                }
                if (cp.Type_id_PromotionType == 422)
                {
                    if (shop.id != cp.Supplier_id)
                    {
                        continue;
                    }
                }
                //检查会员组别
                if (!("," + cp.UserLevel_ids + ",").Contains("," + CurrentUserLevel.id + ","))
                {
                    continue;
                }

                bool flag = true;
                string where = "1=1";
                List <Lebi_User_Product> sps = null;
                foreach (Lebi_Promotion p in Promotion.GetPromotion(cp.id))//只匹配一个条件
                {
                    flag = true;
                    if (p.Case804 == "")
                    {
                        p.Case804 = "0";
                    }
                    if (p.Case805 == "")
                    {
                        p.Case805 = "0";
                    }
                    //验证订单金额:801
                    if (p.IsCase801 == 1)
                    {
                        if (Money_Product_begin < p.Case801)
                        {
                            flag = false;
                            continue;
                        }
                    }
                    //验证订单商品数量:802

                    if (p.IsCase802 == 1)
                    {
                        if (Count < p.Case802)
                        {
                            flag = false;
                            continue;
                        }
                    }
                    //验证商品分类:804
                    if (p.IsCase804 == 1)
                    {
                        where += " and Pro_Type_id in (" + p.Case804 + ")";
                        if (B_Lebi_Product.Counts("id in (" + pids + ") and Pro_Type_id in (" + p.Case804 + ")") == 0)
                        {
                            flag = false;
                            continue;
                        }
                    }
                    //验证限制商品:805
                    if (p.IsCase805 == 1)
                    {
                        where += "and id in (" + p.Case805 + ")";
                        if (B_Lebi_Product.Counts("id in (" + pids + ") and id in (" + p.Case805 + ")") == 0)
                        {
                            flag = false;
                            continue;
                        }
                    }
                    //验证单品数量:803
                    if (p.IsCase803 == 1)
                    {
                        string tids = "0";
                        //取出购物车中,数量大于水平线的商品
                        foreach (Lebi_User_Product up in Products)
                        {
                            if (up.count >= p.Case803)
                            {
                                tids += "," + up.Product_id;
                            }
                        }
                        if (tids == "0")
                        {
                            flag = false;
                            continue;
                        }
                        where += " and id in (" + tids + ")";
                        if (B_Lebi_Product.Counts(where) == 0)
                        {
                            flag = false;
                            continue;
                        }
                    }
                    //验证订单内指定商品数量:806
                    if (p.IsCase806 == 1)
                    {
                        if (p.Case804 == "" && p.Case805 == "")//未设置限制条件的话,直接失败
                        {
                            flag = false;
                            continue;
                        }
                        int count = 0;
                        //计算购物车中包含商品的总数
                        foreach (Lebi_User_Product up in Products)
                        {
                            if (("," + p.Case804 + ",").Contains("," + up.Pro_Type_id + ",") || ("," + p.Case805 + ",").Contains("," + up.Product_id + ","))
                            {
                                count = count + up.count;
                            }
                        }
                        if (count < p.Case806)
                        {
                            flag = false;
                            continue;
                        }
                    }
                    //条件检查结束
                    if (flag)
                    {
                        //取出验证成功的指定商品
                        sps = B_Lebi_User_Product.GetList("User_id=" + CurrentUser.id + " and type_id_UserProductType=142 and Product_id in (select id from [Lebi_Product] where " + where + ")", "");

                        //计算定额运费901
                        if (p.IsRule901 == 1)
                        {
                            Money_Transport_One = p.Rule901;
                            IsTransportPriceOne = true;
                        }
                        //计算折扣902
                        if (p.IsRule902 == 1)
                        {
                            foreach (Lebi_User_Product pro in Products)
                            {
                                pro.Discount = pro.Discount * p.Rule902 / 100;
                            }
                        }
                        //计算指定商品折扣903
                        if (p.IsRule903 == 1)
                        {
                            if (sps != null)
                            {
                                foreach (Lebi_User_Product pro in Products)
                                {
                                    foreach (Lebi_User_Product sp in sps)
                                    {
                                        if (pro.id == sp.id)
                                        {
                                            pro.Discount = pro.Discount * p.Rule903 / 100;
                                        }
                                    }
                                }
                            }
                        }
                        //计算减免金额904
                        if (p.IsRule904 == 1)
                        {
                            Money_Cut = p.Rule904;
                        }
                        //计算返还金额905
                        if (p.IsRule905 == 1)
                        {
                            Money_Give = p.Rule905;
                        }
                        //计算赠送积分906
                        if (p.IsRule906 == 1)
                        {
                            Point_Free = p.Rule906;
                        }
                        //计算翻倍积分907
                        if (p.IsRule907 == 1)
                        {
                            foreach (Lebi_User_Product pro in Products)
                            {
                                pro.Pointagain = pro.Pointagain + p.Rule907;
                            }
                        }
                        //计算指定商品折扣翻倍积分908
                        if (p.IsRule908 == 1)
                        {
                            if (sps != null)
                            {
                                foreach (Lebi_User_Product pro in Products)
                                {
                                    foreach (Lebi_User_Product sp in sps)
                                    {
                                        if (pro.id == sp.id)
                                        {
                                            pro.Pointagain = pro.Pointagain + p.Rule908;
                                        }
                                    }
                                }
                            }
                        }
                        //赠送商品909
                        if (p.IsRule909 == 1)
                        {
                            //暂时不做
                        }
                        //赠送指定商品910
                        if (p.IsRule910 == 1)
                        {
                            if (sps != null)
                            {
                                foreach (Lebi_User_Product sp in sps)
                                {
                                    sp.count         = p.Rule910;
                                    sp.Product_Price = 0;
                                    sp.Product_Point = 0;
                                    sp.Pointagain    = 0;
                                    sp.Discount      = 0;
                                    FreeProducts.Add(sp);
                                }
                            }
                        }
                        //第N个指定商品打折
                        if (p.IsRule912 == 1 && p.IsCase803 == 1 && p.Case803 > 0)
                        {
                            foreach (Lebi_User_Product pro in Products)
                            {
                                foreach (Lebi_User_Product sp in sps)
                                {
                                    if (pro.id == sp.id)
                                    {
                                        if (pro.count > p.Case803)
                                        {
                                            int n = sp.count / p.Case803;
                                            Money_Cut = Money_Cut + pro.Product_Price * (100 - p.Rule912) / 100 * n;
                                        }
                                    }
                                }
                            }
                        }
                        //重新计算价格积分,

                        Money_Product = 0;
                        Point_Product = 0;
                        Point         = 0;
                        foreach (Lebi_User_Product pro in Products)
                        {
                            Money_Product += Math.Round(pro.Product_Price * pro.count * pro.Discount / 100, 2);
                            Point_Product += Math.Round(pro.Product_Point * pro.count * pro.Pointagain);
                            Point          = Point_Product + Point_Free;
                        }

                        break;//验证成功不再验证
                    }
                }
                if (flag)
                {
                    PromotionTypes.Add(cp);
                }
            }
            basketshop = new BasketShop();
            basketshop.FreeProducts        = FreeProducts;
            basketshop.Money_Cut           = Money_Cut;
            basketshop.Money_Give          = Money_Give;
            basketshop.Money_Market        = Money_Market;
            basketshop.Money_Product       = Money_Product;
            basketshop.Money_Product_begin = Money_Product_begin;
            basketshop.Money_Transport     = 0;
            basketshop.Point               = Point;
            basketshop.Point_Free          = Point_Free;
            basketshop.Point_Buy           = Point_Buy;
            basketshop.Point_Product       = Point_Product;
            basketshop.Products            = Products;
            basketshop.PromotionTypes      = PromotionTypes;
            basketshop.Shop                = shop;
            basketshop.Volume              = Volume;
            basketshop.Weight              = Weight;
            basketshop.IsTransportPriceOne = IsTransportPriceOne;
            basketshop.Money_Transport_One = Money_Transport_One;
            basketshop.Count               = Count;
            basketshop.Money_Property      = Money_Property;
            return(basketshop);
        }
Пример #21
0
        public static Model Info(Lebi_User user)
        {
            BaseConfig bc     = ShopCache.GetBaseConfig();
            Model      m      = new Model();
            decimal    Money  = 0;
            string     money_ = Common.GetValue("select sum(Money) from Lebi_Agent_Money where User_id=" + user.id + " and Type_id_AgentMoneyStatus=382 and datediff(d,Time_add,'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')>" + bc.CommissionMoneyDays + "");

            decimal.TryParse(money_, out Money);
            int UserCount = 0;

            UserCount = B_Lebi_User.Counts("User_id_parent=" + user.id + "");
            int UserCountmonth = 0;

            UserCountmonth = B_Lebi_User.Counts("User_id_parent=" + user.id + " and (datediff(d,Time_Reg,'" + System.DateTime.Now.Date.AddDays(0 - System.DateTime.Now.Day + 1).ToString("yyyy-MM-dd") + "')<=0 and datediff(d,Time_Reg,'" + System.DateTime.Now + "')>=0)");
            int UserCountday = 0;

            UserCountday = B_Lebi_User.Counts("User_id_parent=" + user.id + " and (datediff(d,Time_Reg,'" + System.DateTime.Now.Date.ToString("yyyy-MM-dd") + "')<=0 and datediff(d,Time_Reg,'" + System.DateTime.Now + "')>=0)");
            decimal Commission1 = 0;
            decimal Commission2 = 0;
            decimal Commission3 = 0;

            decimal.TryParse(bc.Angent1_Commission, out Commission1);
            decimal.TryParse(bc.Angent2_Commission, out Commission2);
            decimal.TryParse(bc.Angent3_Commission, out Commission3);
            if (user.DT_id == 0)
            {
                Lebi_Agent_UserLevel agent_userlevel = B_Lebi_Agent_UserLevel.GetModel("UserLevel_id = " + user.UserLevel_id + "");
                if (agent_userlevel != null)
                {
                    if (agent_userlevel.Angent1_Commission != -1)
                    {
                        Commission1 = agent_userlevel.Angent1_Commission;
                    }
                    if (agent_userlevel.Angent2_Commission != -1)
                    {
                        Commission2 = agent_userlevel.Angent2_Commission;
                    }
                    if (agent_userlevel.Angent3_Commission != -3)
                    {
                        Commission3 = agent_userlevel.Angent3_Commission;
                    }
                }
                Lebi_Agent_User agent_user = B_Lebi_Agent_User.GetModel("User_id = " + user.id + "");
                if (agent_user != null)
                {
                    if (agent_user.Angent1_Commission != -1)
                    {
                        Commission1 = agent_user.Angent1_Commission;
                    }
                    if (agent_user.Angent2_Commission != -1)
                    {
                        Commission2 = agent_user.Angent2_Commission;
                    }
                    if (agent_user.Angent3_Commission != -1)
                    {
                        Commission3 = agent_user.Angent3_Commission;
                    }
                }
            }
            else
            {
                Lebi_DT_Agent dt_agent = B_Lebi_DT_Agent.GetModel("DT_id = " + user.DT_id + "");
                if (dt_agent != null)
                {
                    if (dt_agent.IsUsedAgent == 1)
                    {
                        Commission1 = dt_agent.Angent1_Commission;
                        Commission2 = dt_agent.Angent2_Commission;
                        Commission3 = dt_agent.Angent3_Commission;
                    }
                }
            }
            m.Money          = Money;
            m.UserCount      = UserCount;
            m.UserCountmonth = UserCountmonth;
            m.UserCountday   = UserCountday;
            m.Commission1    = Commission1;
            m.Commission2    = Commission2;
            m.Commission3    = Commission3;
            Lebi_UserLevel userlevel = B_Lebi_UserLevel.GetModel(user.UserLevel_id);

            if (userlevel != null)
            {
                if (userlevel.IsUsedAgent == 0) //关闭注册
                {
                    m.Commission1 = 0;
                    m.Commission2 = 0;
                    m.Commission3 = 0;
                }
            }
            return(m);
        }
Пример #22
0
        public string Login(string back, int IsLogin = 1)
        {
            string        code = RequestTool.RequestString("code");
            string        res  = "";
            StringBuilder sb;

            if (code != "")
            {
                sb = new StringBuilder();
                sb.Append("?grant_type=authorization_code");
                sb.Append("&client_id=" + appid);
                sb.Append("&client_secret=" + appkey);
                sb.Append("&code=" + code);
                sb.Append("&redirect_uri=" + reurnurl);
                //res = APIURL("oauth/access_token", sb.ToString());
                res = PostAPI("oauth/access_token", sb.ToString());
                //access_token=
                //CAAGUzrOw7
                //AMBADkwUNj
                //HkI9FwLPHD
                //fUamZCSBH1
                //NbSFsKVVjF
                //D2QfmP0aXT
                //FtMTY8e8d5
                //yse93demVg
                //YwCfEWXApj
                //ZAsGqt3ugg
                //YiHSmFQeN2
                //EOwFindWuw
                //R9QHiTlAwr
                //kmuTmr1Qs4
                //mwtSAZC15m
                //wTpLWvZCaj
                //OkVC1zlTZB
                //B5gjRZBmCm
                //C2j&expires=5183999
                //HttpContext.Current.Response.Redirect(res);
                res = res + "&";
                string access_token = RegexTool.GetRegValue(res, "access_token=(.*?)&");

                JavaScriptSerializer jss = new JavaScriptSerializer();
                //获取uid
                sb = new StringBuilder();
                sb.Append("?access_token=" + access_token);
                res = GetAPI("me", sb.ToString());

                Model.Facebook.userinfo model = jss.Deserialize <Model.Facebook.userinfo>(res);
                string uid = model.id;
                //return uid;
                Lebi_User user = B_Lebi_User.GetModel("bind_facebook_id='" + uid + "'");

                if (model == null)
                {
                    model = new Model.Facebook.userinfo();
                }
                if (model.picture == null)
                {
                    model.picture = new Model.Facebook.userinfo.picture_();
                }
                if (model.picture.data == null)
                {
                    model.picture.data     = new Model.Facebook.userinfo.picture_.data_();
                    model.picture.data.url = "";
                }
                string username = model.last_name + model.first_name;
                if (user == null)
                {
                    Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                    if (defaultlevel == null)
                    {
                        defaultlevel = new Lebi_UserLevel();
                    }
                    if (defaultlevel.RegisterType == 0) //关闭注册
                    {
                        return("会员注册已关闭");
                    }
                    user = new Lebi_User();
                    user.bind_facebook_id       = uid;
                    user.bind_facebook_nickname = username;
                    user.bind_facebook_token    = access_token;
                    user.Face              = model.picture.data.url;
                    user.UserName          = username;
                    user.Password          = EX_User.MD5(uid);
                    user.Language          = Language.CurrentLanguage().Code;
                    user.Sex               = model.gender == "female" ? "女" : "男";
                    user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                    user.IsPlatformAccount = 1;
                    if (CurrentSite != null)
                    {
                        user.Site_id = CurrentSite.id;
                    }
                    user.DT_id = DT_id;
                    B_Lebi_User.Add(user);
                    user.id = B_Lebi_User.GetMaxId();
                    EX_User.LoginOK(user);
                }
                else
                {
                    user.bind_facebook_id       = uid;
                    user.bind_facebook_nickname = username;
                    user.bind_facebook_token    = access_token;
                    user.Face     = model.picture.data.url;
                    user.Sex      = model.gender == "female" ? "女" : "男";
                    user.UserName = username;
                    user.DT_id    = DT_id;
                    B_Lebi_User.Update(user);
                    EX_User.LoginOK(user);
                }
                return("OK");
            }
            return("授权失败");
        }
Пример #23
0
        public string Login(string back, int IsLogin = 1)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("?grant_type=authorization_code");
                    sb.Append("&client_id=" + appid);
                    sb.Append("&client_secret=" + appkey);
                    sb.Append("&code=" + code);
                    string uri = reurnurl + "?backurl=" + ENBackuri(back);
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    sb.Append("&redirect_uri=" + uri);
                    string res = PostAPI("token", sb.ToString());

                    JavaScriptSerializer jss   = new JavaScriptSerializer();
                    Model.Taobao.token   token = jss.Deserialize <Model.Taobao.token>(res);
                    string access_token        = token.access_token;
                    string uid      = token.taobao_user_id;
                    string username = token.taobao_user_nick;
                    //获取详细个人信息

                    sb = new StringBuilder();
                    sb.Append("&access_token=" + access_token);
                    res = GetAPI("taobao.user.buyer.get", sb.ToString(), false);


                    Model.Taobao.userinfo model = jss.Deserialize <Model.Taobao.userinfo>(res);
                    if (model == null)
                    {
                        model = new Model.Taobao.userinfo();
                    }
                    if (model.user_buyer_get_response == null)
                    {
                        model.user_buyer_get_response = new Model.Taobao.userinfo.user_buyer_get_response_();
                    }
                    if (model.user_buyer_get_response.user == null)
                    {
                        model.user_buyer_get_response.user        = new Model.Taobao.userinfo.user_buyer_get_response_.user_();
                        model.user_buyer_get_response.user.sex    = "m";
                        model.user_buyer_get_response.user.avatar = "";
                    }
                    if (model.user_buyer_get_response.user.location == null)
                    {
                        model.user_buyer_get_response.user.location = new Model.Taobao.userinfo.user_buyer_get_response_.user_.location_();
                    }
                    string where = "bind_taobao_id='" + uid + "'";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User CurrentUser = EX_User.CurrentUser();
                    if (CurrentUser.id > 0)//已经登录
                    {
                        if (IsLogin == 0)
                        {
                            if (user != null)
                            {
                                if (CurrentUser.id != user.id)
                                {
                                    return("已绑定其它帐号");
                                }
                            }
                        }
                        CurrentUser.bind_taobao_id       = uid;
                        CurrentUser.bind_taobao_nickname = username;
                        CurrentUser.bind_taobao_token    = access_token;
                        if (CurrentUser.Face == "")
                        {
                            CurrentUser.Face = model.user_buyer_get_response.user.avatar;//头像
                        }
                        CurrentUser.DT_id = DT_id;
                        B_Lebi_User.Update(CurrentUser);
                    }
                    else
                    {
                        if (user == null)
                        {
                            Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                            if (defaultlevel == null)
                            {
                                defaultlevel = new Lebi_UserLevel();
                            }
                            if (defaultlevel.RegisterType == 0) //关闭注册
                            {
                                return("会员注册已关闭");
                            }
                            user = new Lebi_User();
                            user.bind_taobao_id       = uid;
                            user.bind_taobao_nickname = username;
                            user.bind_taobao_token    = access_token;
                            user.UserName             = "******" + uid;
                            user.NickName             = username;
                            user.Password             = EX_User.MD5(uid);
                            user.Language             = Language.CurrentLanguage().Code;
                            user.Sex               = model.user_buyer_get_response.user.sex == "f" ? "女" : "男";
                            user.Face              = model.user_buyer_get_response.user.avatar;//头像
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            if (CurrentSite != null)
                            {
                                user.Site_id = CurrentSite.id;
                            }
                            user.DT_id = DT_id;
                            B_Lebi_User.Add(user);
                            user.id = B_Lebi_User.GetMaxId();
                            EX_User.LoginOK(user);
                        }
                        else
                        {
                            user.bind_taobao_id       = uid;
                            user.bind_taobao_nickname = username;
                            user.bind_taobao_token    = access_token;
                            if (user.Face == "")
                            {
                                user.Face = model.user_buyer_get_response.user.avatar;//头像
                            }
                            //user.Sex = model.user_buyer_get_response.user.sex == "f" ? "女" : "男";
                            user.DT_id = DT_id;
                            B_Lebi_User.Update(user);
                            EX_User.LoginOK(user);
                        }
                    }
                    return("OK");
                }
                catch
                {
                    return("授权失败");
                }
            }
            return("授权失败");
        }
Пример #24
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_UserLevel SafeBindForm(Lebi_UserLevel model)
 {
     return(D_Lebi_UserLevel.Instance.SafeBindForm(model));
 }
Пример #25
0
        /// <summary>
        /// 微信登录
        /// https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
        /// </summary>
        /// <param name="back"></param>
        /// <returns></returns>
        public string Login(string back, int IsLogin = 1)
        {
            string code = RequestTool.RequestString("code");

            if (code != "")
            {
                try
                {
                    string uri    = reurnurl + "?backurl=" + ENBackuri(back);
                    int    userid = 0;
                    uri = System.Web.HttpUtility.UrlEncode(uri);
                    string res = Post("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + appkey + "&code=" + code + "&grant_type=authorization_code");
                    JavaScriptSerializer jss = new JavaScriptSerializer();

                    Model.weixin.tokeninfo tokeninfo = jss.Deserialize <Model.weixin.tokeninfo>(res);
                    string uid = tokeninfo.openid;
                    //SystemLog.Add(uid);
                    //获取用户资料
                    //https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
                    res = Post("https://api.weixin.qq.com/sns/userinfo?access_token=" + tokeninfo.access_token + "&openid=" + uid + "&lang=zh_CN");

                    Model.weixin.userinfo model = jss.Deserialize <Model.weixin.userinfo>(res);
                    string where = "bind_weixin_id='" + uid + "' and bind_weixin_id!=''";
                    //if (DT_id > 0)
                    //{
                    //    where += " and DT_id =" + DT_id + "";
                    //}
                    Lebi_User user        = B_Lebi_User.GetModel(where);
                    Lebi_User CurrentUser = null;
                    string    qrcodeid_   = RegexTool.GetRegValue((back + "&"), @"qrcodeid=(\d*)&");
                    int       qrid        = 0;
                    int.TryParse(qrcodeid_, out qrid);
                    if (qrid > 0)
                    {
                        //扫描二维码授权绑定当前账号
                        Lebi_weixin_qrcode qcode = B_Lebi_weixin_qrcode.GetModel(qrid);
                        CurrentUser = B_Lebi_User.GetModel(qcode.User_id);
                        if (IsLogin == 0)
                        {
                            if (user != null && CurrentUser != null)
                            {
                                return("已绑定其它帐号");
                            }
                        }
                    }

                    if (user == null)
                    {
                        Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc");
                        if (defaultlevel == null)
                        {
                            defaultlevel = new Lebi_UserLevel();
                        }
                        if (defaultlevel.RegisterType == 0) //关闭注册
                        {
                            return("会员注册已关闭");
                        }
                        if (CurrentUser == null)
                        {
                            user = new Lebi_User();
                            user.bind_weixin_id       = uid;
                            user.bind_weixin_nickname = model.nickname;
                            user.bind_weixin_token    = tokeninfo.access_token;
                            try
                            {
                                user.Face = DownLoadImage(model.headimgurl);
                            }
                            catch
                            {
                                user.Face = model.headimgurl;
                            }
                            user.NickName          = model.nickname;
                            user.UserName          = "******" + uid;
                            user.Password          = EX_User.MD5(uid);
                            user.Language          = Language.CurrentLanguage().Code;
                            user.Sex               = model.sex == "2" ? "女" : "男";
                            user.UserLevel_id      = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id;
                            user.IsPlatformAccount = 1;
                            //B_Lebi_User.Add(user);
                            //user.id = B_Lebi_User.GetMaxId();
                            //userid = user.id;
                            user.DT_id = DT_id;
                            EX_User.UserReg(user);
                        }
                        else
                        {
                            CurrentUser.bind_weixin_id       = uid;
                            CurrentUser.bind_weixin_nickname = model.nickname;
                            CurrentUser.bind_weixin_token    = tokeninfo.access_token;

                            try
                            {
                                CurrentUser.Face = DownLoadImage(model.headimgurl);
                            }
                            catch
                            {
                                CurrentUser.Face = model.headimgurl;
                            }
                            //CurrentUser.Face = model.headimgurl;//头像 50*50

                            if (CurrentUser.NickName == "")
                            {
                                CurrentUser.NickName = model.nickname;
                            }
                            CurrentUser.DT_id = DT_id;
                            //B_Lebi_User.Update(CurrentUser);
                            EX_User.LoginOK(CurrentUser, 0);
                            userid = CurrentUser.id;
                        }
                    }
                    else
                    {
                        user.bind_weixin_id       = uid;
                        user.bind_weixin_nickname = model.nickname;
                        user.bind_weixin_token    = tokeninfo.access_token;;

                        try
                        {
                            user.Face = DownLoadImage(model.headimgurl);
                        }
                        catch (Exception ex)
                        {
                            user.Face = "";
                            LB.Tools.TxtLog.Add(ex.Message);
                        }

                        if (user.NickName == "")
                        {
                            user.NickName = model.nickname;
                        }
                        user.DT_id = DT_id;
                        //user.Sex = model.gender == "f" ? "女" : "男";
                        //B_Lebi_User.Update(user);
                        EX_User.LoginOK(user, 0);
                        userid = user.id;
                    }


                    if (qrid > 0)
                    {
                        //扫描二维码登录
                        Lebi_weixin_qrcode qcode = B_Lebi_weixin_qrcode.GetModel(qrid);
                        qcode.User_id = userid;
                        B_Lebi_weixin_qrcode.Update(qcode);
                        //Log.Add(back);
                    }
                    return("OK");
                }
                catch (Exception ex)
                {
                    LB.Tools.TxtLog.Add(ex.Message);
                    return("授权失败" + ex.Message);
                }
            }
            return("授权失败");
        }