Exemple #1
0
        /// <summary>
        /// 更新商家资金
        /// </summary>
        /// <param name="user"></param>
        public static void UpdateUserMoney(Lebi_Supplier user)
        {
            string  money = B_Lebi_Supplier_Money.GetValue("sum(Money)", "Supplier_id=" + user.id + " and Type_id_MoneyStatus=181");
            decimal Money = 0;

            Decimal.TryParse(money, out Money);
            user.Money = Money;
            B_Lebi_Supplier.Update(user);
        }
Exemple #2
0
        //public static bool CheckPower(string code, string name)
        //{
        //    if (!Power(code, name))
        //    {
        //        NoPower();
        //        return false;
        //    }
        //    return true;
        //}
        //public static void NoPower()
        //{
        //    HttpContext.Current.Response.Write("{\"msg\":\"权限不足\"}");
        //    HttpContext.Current.Response.End();
        //}
        #endregion

        /// <summary>
        /// 供应商账号登录
        /// </summary>
        /// <param name="user"></param>
        /// <param name="type">账号类型</param>
        /// <param name="supplierid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool Login(Lebi_User user, string type, int supplierid, out string msg, int adminlogin = 0)
        {
            msg = "OK";
            Lebi_Supplier_User supplieruser = null;
            Lebi_Supplier      supplier     = null;

            if (supplierid == 0)
            {
                string supplierid_ = CookieTool.GetCookieString("supplier");
                //int supplierid = 0;
                int.TryParse(supplierid_, out supplierid);
            }
            //string and = "";
            //if (type != "")
            //{
            //    and = " and Supplier_id in (select id from [Lebi_Supplier] where Supplier_Group_id in (select id from [Lebi_Supplier_Group] where type='" + type + "'))";
            //}
            if (supplierid > 0)
            {
                supplier = B_Lebi_Supplier.GetModel(supplierid);
                if (supplier != null)
                {
                    Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id);
                    if (group.type == type || type == "")
                    {
                        supplieruser = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011");
                    }
                }
            }
            if (supplieruser == null)
            {
                List <Lebi_Supplier_User> users = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "");
                if (type == "")
                {
                    foreach (Lebi_Supplier_User u in users)
                    {
                        supplier = B_Lebi_Supplier.GetModel(u.Supplier_id);
                        if (supplier != null)
                        {
                            supplieruser = u;
                            break;
                        }
                    }
                    //supplieruser = users.FirstOrDefault();
                    //if (supplieruser == null)
                    //{
                    //    msg = "User_id = " + user.id + " and Type_id_SupplierUserStatus=9011";
                    //    return false;
                    //}
                    //supplier = B_Lebi_Supplier.GetModel(supplieruser.Supplier_id);
                }
                else
                {
                    foreach (Lebi_Supplier_User u in users)
                    {
                        supplier = B_Lebi_Supplier.GetModel(u.Supplier_id);
                        if (supplier == null)
                        {
                            continue;
                        }
                        Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id);
                        if (group.type == type)
                        {
                            supplieruser = u;
                            break;
                        }
                    }
                }
            }
            if (supplieruser == null)
            {
                Log.Add("登陆失败", "Login", "", supplier, "账号:" + user.UserName);
                msg = "登陆失败";
                return(false);
            }
            if (supplier == null)
            {
                Log.Add("登陆失败:账号不存在或不可用", "Login", "", supplier, "账号:" + user.UserName);
                msg = "账号不存在或不可用";
                return(false);
            }
            if (supplier.Type_id_SupplierStatus != 442)
            {
                Log.Add("登陆失败:供应商账号不可用", "Login", "", supplier, "账号:" + user.UserName);
                msg = "供应商账号不可用";
                return(false);
            }
            supplier.Time_Last = supplier.Time_This;
            supplier.Time_This = DateTime.Now;
            supplier.Count_Login++;
            supplier.IP_Last = supplier.IP_This;
            supplier.IP_This = RequestTool.GetClientIP();
            Shop.Tools.CookieTool.SetCookieString("supplier", supplier.id.ToString(), 60 * 24);
            B_Lebi_Supplier.Update(supplier);
            if (adminlogin == 0)
            {
                Log.Add("登陆系统", "Login", "", supplier, "账号:" + user.UserName);
            }
            return(true);
        }