Пример #1
0
        /// <summary>
        /// 返回当前币种
        /// 前台使用
        /// </summary>
        /// <returns></returns>
        public static Lebi_Currency CurrentCurrency(Lebi_Language lang)
        {
            string        code  = CookieTool.GetCookieString("Currency");
            Lebi_Currency model = B_Lebi_Currency.GetModel("Code=lbsql{'" + code + "'}");

            if (model == null)
            {
                model = B_Lebi_Currency.GetModel(lang.Currency_id);
            }
            if (model == null)
            {
                return(DefaultCurrency());
            }
            return(model);
        }
Пример #2
0
        /// <summary>
        /// 当前供应商用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static Lebi_Supplier_User CurrentSupplierUser(Lebi_User user)
        {
            Lebi_Supplier_User model       = null;
            string             supplierid_ = CookieTool.GetCookieString("supplier");
            int supplierid = 0;

            int.TryParse(supplierid_, out supplierid);
            if (supplierid > 0)
            {
                model = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011");
            }
            if (model == null)
            {
                model = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "").FirstOrDefault();
            }
            if (model == null)
            {
                model = new Lebi_Supplier_User();
            }
            return(model);
        }
Пример #3
0
        /// <summary>
        /// 验证微信是否已经授权-登陆账号
        /// </summary>
        public void wechatlogin()
        {
            string cid = CookieTool.GetCookieString("qrcodeid");
            int    id  = 0;

            if (cid != "")
            {
                int.TryParse(cid, out id);
                Lebi_weixin_qrcode model = B_Lebi_weixin_qrcode.GetModel(id);
                if (model != null)
                {
                    if (model.User_id > 0)
                    {
                        //CookieTool.SetCookieString("qrcodeid", "0", -1);
                        CookieTool.DeleteCookie("qrcodeid");
                        Lebi_User user = B_Lebi_User.GetModel(model.User_id);
                        EX_User.LoginOK(user);
                        Response.Write("{\"msg\":\"OK\"}");
                        return;
                    }
                }
            }
            Response.Write("{\"msg\":\"NO\"}");
        }
Пример #4
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);
        }
Пример #5
0
        /// <summary>
        /// 生成登录二维码
        /// </summary>
        public void GetQrCode()
        {
            string             cid   = CookieTool.GetCookieString("qrcodeid");
            int                id    = 0;
            string             url   = "";
            int                DT_id = ShopPage.GetDT();
            Lebi_weixin_qrcode model;

            int.TryParse(cid, out id);
            string where = "id='" + id + "'";
            if (DT_id > 0)
            {
                where += " and DT_id =" + DT_id + "";
            }
            model = B_Lebi_weixin_qrcode.GetModel(where);
            if (model == null)
            {
                model         = new Lebi_weixin_qrcode();
                model.User_id = CurrentUser.id;
                model.DT_id   = DT_id;
                B_Lebi_weixin_qrcode.Add(model);
                id = B_Lebi_weixin_qrcode.GetMaxId();
                CookieTool.SetCookieString("qrcodeid", id.ToString(), 60);
            }
            string token   = RequestTool.RequestString("token");
            string backurl = RequestTool.RequestString("url");

            backurl = HttpUtility.UrlDecode(backurl);
            if (EX_User.MD5(SYS.InstallCode + backurl) != token)
            {
                backurl = URL("P_Index", "");
            }

            if (backurl.Contains("?"))
            {
                backurl += "&qrcodeid=" + id;
            }
            else
            {
                backurl += "?qrcodeid=" + id;
            }
            backurl = HttpUtility.UrlEncode(backurl);
            url     = Shop.Platform.weixin.GetInstance(DT_id, CurrentSite).LoginURL(backurl);
            //QRCode.Instance.CreateImage(url, id.ToString());
            Bitmap image = QRCode.Instance.CreateImage(url);

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            Response.ClearContent();
            Response.ContentType = "image/Gif";
            Response.BinaryWrite(ms.ToArray());
            //删除60分钟前的二维码
            //string where = "datediff(n,Time_add,'" + System.DateTime.Now + "')>60";
            //List<Lebi_weixin_qrcode> qs = B_Lebi_weixin_qrcode.GetList(where, "");
            //foreach (Lebi_weixin_qrcode q in qs)
            //{
            //    ImageHelper.DeleteImage("/qrcode/" + q.id + ".png");
            //}
            //B_Lebi_weixin_qrcode.Delete(where);
            ////================
            //Response.Write("{\"msg\":\"OK\",\"img\":\"" + WebPath + "/qrcode/" + id + ".png\"}");
        }
Пример #6
0
        public decimal Money_Tax              = 0;        //税金
        /// <summary>
        /// sid=0,取得全部供应商的商品
        /// </summary>
        /// <param name="type"></param>
        public Basket(int sid)
        {
            Products = Basket.UserProduct(CurrentUser, 142);

            PromotionTypes = new List <Lebi_Promotion_Type>();
            FreeProducts   = new List <Lebi_User_Product>();
            Shops          = new List <BasketShop>();
            List <BasketShop> tempShops   = new List <BasketShop>();
            List <string>     brandstring = new List <string>();

            foreach (Lebi_User_Product pro in Products)
            {
                try
                {
                    Lebi_Product product = B_Lebi_Product.GetModel(pro.Product_id);
                    if (product == null)
                    {
                        continue;
                    }
                    bool ishavebrand = false;
                    for (int i = 0; i < brandstring.Count(); i++)
                    {
                        if (brandstring[i].Contains(product.Brand_id.ToString() + ":"))
                        {
                            brandstring[i] += "," + pro.Product_id;
                            ishavebrand     = true;
                            break;
                        }
                    }
                    if (!ishavebrand)
                    {
                        brandstring.Add(product.Brand_id.ToString() + ":" + pro.Product_id);
                    }
                    if (product.Type_id_ProductType == 324)        //预定商品
                    {
                        pro.Product_Price = product.Price_reserve; //预定金额
                    }
                    else
                    {
                        pro.Product_Price = EX_Product.ProductPrice(product, CurrentUserLevel, CurrentUser, pro.count);//单价
                    }
                    //<-{计算品牌不含税商品总额  by lebi.kingdge 2015-08-22
                    Lebi_Brand brand = B_Lebi_Brand.GetModel(product.Brand_id);
                    if (brand != null)
                    {
                        if (brand.IsVAT == 0)
                        {
                            Money_Product_NOVAT += pro.Product_Price * pro.count;
                        }
                    }
                    //}->
                    Lebi_Supplier shop = B_Lebi_Supplier.GetModel(product.Supplier_id);
                    if (shop == null)
                    {
                        product.Supplier_id = 0;    //容错,商品供应商删除时,商城发货
                        shop = new Lebi_Supplier(); //自营商品
                    }
                    else
                    {
                        if (shop.IsSupplierTransport == 0)//商城代发货的情况
                        {
                            product.Supplier_id = 0;
                            shop = new Lebi_Supplier();//自营商品
                        }
                    }

                    BasketShop bshop = (from m in tempShops
                                        where m.Shop.id == product.Supplier_id
                                        select m).ToList().FirstOrDefault();
                    if (bshop == null)
                    {
                        if (product.Supplier_id == 0)
                        {
                            //shop = new Lebi_Supplier();//自营商品
                            bshop          = new BasketShop();
                            bshop.Shop     = shop;
                            bshop.Products = new List <Lebi_User_Product>();
                            tempShops.Add(bshop);
                        }
                        else
                        {
                            bshop          = new BasketShop();
                            bshop.Shop     = shop;
                            bshop.Products = new List <Lebi_User_Product>();
                            tempShops.Add(bshop);
                        }
                    }
                    (from m in tempShops
                     where m.Shop.id == product.Supplier_id
                     select m).ToList().FirstOrDefault().Products.Add(pro);
                }
                catch (System.NullReferenceException)
                {
                }
            }
            tempShops = tempShops.OrderBy(a => a.Shop.id).ToList();
            if (SYS.IsSupplierCash == "1")
            {
                if (sid == 0)
                {
                    sid = RequestTool.RequestInt("sid");
                }
                if (sid == 0)
                {
                    string tempid = CookieTool.GetCookieString("supplier");
                    int.TryParse(tempid, out sid);
                }
                cashsupplierid = sid;
                bool flag = false;
                foreach (BasketShop shop in tempShops)
                {
                    if (shop.Shop.IsCash == 1)
                    {
                        IsMutiCash = true;
                    }
                    if (shop.Shop.id == cashsupplierid)
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    try
                    {
                        cashsupplierid = tempShops.FirstOrDefault().Shop.id;
                    }
                    catch
                    {
                        cashsupplierid = 0;
                    }
                }

                if (sid > 0)
                {
                    //只保留当前结算供应商的数据
                    List <int> ids = new List <int>();
                    for (int i = 0; i < tempShops.Count; i++)
                    {
                        if (tempShops[i].Shop.id == cashsupplierid)
                        {
                            Shops.Add(tempShops[i]);
                        }
                    }
                }
                else
                {
                    Shops = tempShops;
                }
            }
            else
            {
                Shops = tempShops;
            }
            Products = new List <Lebi_User_Product>();
            for (int i = 0; i < Shops.Count; i++)
            {
                Shops[i]             = SetMoneyAndPoint(CurrentUser, CurrentUserLevel, Shops[i]);
                Weight              += Shops[i].Weight;
                Volume              += Shops[i].Volume;
                Money_Product       += Shops[i].Money_Product;
                Money_Product_begin += Shops[i].Money_Product_begin;
                Money_Property      += Shops[i].Money_Property;
                Money_Cut           += Shops[i].Money_Cut;
                Money_Give          += Shops[i].Money_Give;
                Money_Market        += Shops[i].Money_Market;
                Count         += Shops[i].Count;
                Point         += Shops[i].Point;
                Point_Buy     += Shops[i].Point_Buy;
                Point_Product += Shops[i].Point_Product;
                Point_Free    += Shops[i].Point_Free;
                FreeProducts.AddRange(Shops[i].FreeProducts);
                PromotionTypes.AddRange(Shops[i].PromotionTypes);
                Products.AddRange(Shops[i].Products);
            }
            //<-{退税计算  by lebi.kingdge 2015-08-22
            decimal Refund_MinMoney = 0;
            decimal Refund_VAT      = 0;

            decimal.TryParse(SYS.Refund_MinMoney, out Refund_MinMoney);
            decimal.TryParse(SYS.Refund_VAT, out Refund_VAT);
            if (Refund_MinMoney > 0)
            {
                if ((Money_Product - Money_Product_NOVAT) > Refund_MinMoney)
                {
                    Money_Refund_VAT = (Money_Product - Money_Product_NOVAT) * Refund_VAT / 100;
                    Money_Refund_Fee = Refund_Fee(SYS.Refund_StepR, Money_Refund_VAT, Money_Product - Money_Product_NOVAT);
                    Money_Refund     = Money_Refund_VAT - Money_Refund_Fee;
                }
                else
                {
                    Money_Refund     = 0;
                    Money_Refund_VAT = 0;
                    Money_Refund_Fee = 0;
                }
                //循环品牌计算各品牌退税
                if (Refund_VAT > 0)
                {
                    foreach (string bran in brandstring)
                    {
                        string[]   arr   = bran.Split(':');
                        Lebi_Brand brand = B_Lebi_Brand.GetModel("id=" + arr[0] + " and IsVAT = 1");
                        if (brand != null)
                        {
                            decimal Brand_Money_Product            = 0;
                            decimal OtherSite_Money_Refund_VAT     = 0;
                            decimal OtherSite_Money_Refund_Fee     = 0;
                            List <Lebi_User_Product> user_products = (from m in Products where ("," + arr[1] + ",").Contains("," + m.Product_id + ",") select m).ToList();
                            foreach (Lebi_User_Product user_product in user_products)
                            {
                                Brand_Money_Product += user_product.Product_Price * user_product.count;
                            }
                            if (Brand_Money_Product >= Refund_MinMoney)
                            {
                                OtherSite_Money_Refund_VAT = Brand_Money_Product * Refund_VAT / 100;
                                OtherSite_Money_Refund_Fee = Refund_Fee(SYS.Refund_StepR, OtherSite_Money_Refund_VAT, Brand_Money_Product);
                                OtherSite_Money_Refund    += OtherSite_Money_Refund_VAT - OtherSite_Money_Refund_Fee;
                            }
                        }
                    }
                }
            }
            //}->
            //<-{税金计算  by lebi.kingdge 2017-02-17
            decimal TaxRate = 0;

            decimal.TryParse(SYS.TaxRate, out TaxRate);
            if (TaxRate > 0)
            {
                Money_Tax = Money_Product * TaxRate / 100;
            }
            //}->
        }
Пример #7
0
 /// <summary>
 /// 当前语言
 /// </summary>
 /// <returns></returns>
 public static string CurrentLanguageFlag()
 {
     return(CookieTool.GetCookieString("Language"));
 }
Пример #8
0
        public static Lebi_Language_Code AdminCurrentLanguage()
        {
            string Language = CookieTool.GetCookieString("AdminLanguage");

            return(AdminGetLanguage(Language));
        }