protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode) { LoadTheme(themecode, siteid, languagecode, pcode); int id = Rint_Para("0"); product = GetProduct(id); if (product.id == 0) { Response.Redirect(URL("P_404", "")); Response.End(); } PageSize = 20; pro_type = B_Lebi_Pro_Type.GetModel(product.Pro_Type_id); path = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">»</em>"; if (pro_type != null) { string[,] parr = Categorypath(pro_type.id); for (int i = 0; i <= parr.GetUpperBound(0); i++) { path += "<a href=\"" + URL("P_ProductCategory", "" + parr[i, 0] + "") + "\"><span>" + parr[i, 1] + "</span></a><em>»</em>"; } } path += "<a href=\"" + URL("P_Product", product.id) + "\"><span>" + Lang(product.Name) + "</span></a><em>»</em>"; path += "<a><span>" + Tag("商品咨询") + "</span></a>"; }
/// <summary> /// 卡备注 /// </summary> /// <param name="card"></param> /// <returns></returns> public string CardRemark(Lebi_Card card) { string str = ""; if (card.Money_Buy > 0) { str += Tag("最低消费") + ":" + FormatMoney(card.Money_Buy) + ";"; } if (card.Pro_Type_ids != "") { string tstr = ""; List <Lebi_Pro_Type> ts = B_Lebi_Pro_Type.GetList("id in (" + card.Pro_Type_ids + ")", ""); foreach (Lebi_Pro_Type t in ts) { if (tstr == "") { tstr = Lang(t.Name); } else { tstr += "," + Lang(t.Name); } } str += Tag("限制商品") + ":" + tstr + ";"; } return(str); }
public string Categorypath_ids(int id) { Lebi_Pro_Type model = B_Lebi_Pro_Type.GetModel(id); string str = model.id.ToString(); if (model.Parentid > 0) { str += "," + Categorypath_ids(model.Parentid); } return(str); }
/// <summary> /// 返回某个商品分类下,所有子id的组合 /// 逗号分隔 /// </summary> /// <param name="id"></param> /// <returns></returns> public string Categoryid(int id) { string str = id.ToString(); List <Lebi_Pro_Type> ts = B_Lebi_Pro_Type.GetList("Parentid=" + id + "", "Sort desc"); foreach (Lebi_Pro_Type t in ts) { str += "," + Categoryid(t.id); } return(str); }
/// <summary> /// 返回子分类 /// </summary> /// <param name="id"></param> /// <returns></returns> public List <Lebi_Pro_Type> Cateporys(int id) { List <Lebi_Pro_Type> models = EX_Product.ShowTypes(id, CurrentSite.id); if (models.Count == 0) { Lebi_Pro_Type m = B_Lebi_Pro_Type.GetModel(id); if (m.Parentid > 0) { return(Cateporys(m.Parentid)); } } return(models); }
protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode) { LoadTheme(themecode, siteid, languagecode, pcode); int id = Rint_Para("0"); comment = B_Lebi_Comment.GetModel(id); if (comment.id == 0) { Response.Redirect(URL("P_404", "")); Response.End(); } product = GetProduct(comment.Keyid); string where = "Parentid =" + id; comments = B_Lebi_Comment.GetList(where, "id desc", PageSize, pageindex); int recordCount = B_Lebi_Comment.Counts(where); PageString = Shop.Bussiness.Pager.GetPaginationStringForWeb("?page={0}&id=" + id, pageindex, PageSize, recordCount, CurrentLanguage); ProductStar = Convert.ToInt32(product.Star_Comment); if (ProductStar > 5) { ProductStar = 5; } if (ProductStar < 0) { ProductStar = 0; } pro_type = B_Lebi_Pro_Type.GetModel(product.Pro_Type_id); path = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">»</em>"; if (pro_type != null) { string[,] parr = Categorypath(pro_type.id); for (int i = 0; i <= parr.GetUpperBound(0); i++) { path += "<a href=\"" + URL("P_ProductCategory", "" + parr[i, 0] + "") + "\"><span>" + parr[i, 1] + "</span></a><em>»</em>"; } } path += "<a href=\"" + URL("P_Product", product.id) + "\"><span>" + Lang(product.Name) + "</span></a><em>»</em>"; path += "<a><span>" + Tag("晒单") + "</span></a>"; //path += "<a href=\"" + URL("P_Product", id) + "\"><span>" + Lang(product.Name) + "</span></a>"; smalls = comment.ImagesSmall.Split('@'); bigs = comment.Images.Split('@'); if (bigs.Count() > 1) { DefaultImage = bigs[1]; } productcomments = B_Lebi_Comment.GetList("TableName='Product' and Keyid=" + comment.Keyid + " and id!=" + comment.id + "", "id desc", 5, 1); }
/// <summary> /// 某个商品分类的路径 /// </summary> /// <param name="id"></param> /// <returns></returns> public string[,] Categorypath(int id) { string str = Categorypath_ids(id); string[] arr = str.Split(','); string[,] res = new string[arr.Length, 2]; for (int i = 0; i < arr.Length; i++) { Lebi_Pro_Type model = B_Lebi_Pro_Type.GetModel(int.Parse(arr[i])); int j = arr.Length - i - 1; res[j, 0] = model.id.ToString(); res[j, 1] = Lang(model.Name); } return(res); }
protected int ProductStar;//整数的商品评分,最大为5 protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode) { LoadTheme(themecode, siteid, languagecode, pcode); int id = Rint_Para("0"); product = GetProduct(id); if (product.id == 0) { Response.Redirect(URL("P_404", "")); Response.End(); } string where = "Parentid = 0 and TableName = 'Product' and (Keyid = " + id + ""; if (product.Product_id != 0) { where += " or Product_id = " + product.Product_id + ""; } where += ") and (Status = 281 or User_id = " + CurrentUser.id + ")"; comments = B_Lebi_Comment.GetList(where, "id desc", PageSize, pageindex); int recordCount = B_Lebi_Comment.Counts(where); PageString = Shop.Bussiness.Pager.GetPaginationStringForWeb("?page={0}&id=" + id, pageindex, PageSize, recordCount, CurrentLanguage); ProductStar = Convert.ToInt32(product.Star_Comment); if (ProductStar > 5) { ProductStar = 5; } if (ProductStar < 0) { ProductStar = 0; } pro_type = B_Lebi_Pro_Type.GetModel(product.Pro_Type_id); path = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">»</em>"; if (pro_type != null) { string[,] parr = Categorypath(pro_type.id); for (int i = 0; i <= parr.GetUpperBound(0); i++) { path += "<a href=\"" + URL("P_ProductCategory", "" + parr[i, 0] + "") + "\"><span>" + parr[i, 1] + "</span></a><em>»</em>"; } } path += "<a href=\"" + URL("P_Product", product.id) + "\"><span>" + Lang(product.Name) + "</span></a><em>»</em>"; path += "<a><span>" + Tag("商品评论") + "</span></a>"; }
/// <summary> /// 代金券限制信息 /// </summary> /// <param name="card"></param> /// <returns></returns> public string cardinfo(Lebi_Card card) { string str = ""; if (card.Money_Buy > 0) { str = Tag("最低消费") + ":"; str += FormatMoney(card.Money_Buy); } if (card.Pro_Type_ids != "") { str += " " + Tag("限品类") + ":"; List <Lebi_Pro_Type> ts = B_Lebi_Pro_Type.GetList("id in (" + card.Pro_Type_ids + ")", ""); foreach (Lebi_Pro_Type t in ts) { str += Lang(t.Name); } } return(str); }
/// <summary> /// 某个商品分类的路径 /// </summary> /// <param name="id"></param> /// <returns></returns> public string[,] Categorypath(int id) { string str = Categorypath_ids(id); string[] arr = str.Split(','); string[,] res = new string[arr.Length, 3]; for (int i = 0; i < arr.Length; i++) { Lebi_Pro_Type model = B_Lebi_Pro_Type.GetModel("id = " + int.Parse(arr[i]) + " and IsShow = 1"); if (model == null) { continue; } int j = arr.Length - i - 1; res[j, 0] = model.id.ToString(); res[j, 1] = Lang(model.Name); res[j, 2] = Lang(model.Url); } return(res); }
/// <summary> /// 生成地址重写规则 /// </summary> public static void CreateURLRewrite() { StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); sb.AppendLine("[ISAPI_Rewrite]"); sb1.AppendLine("RewriteEngine On"); sb1.AppendLine("RewriteCompatibility2 On"); sb1.AppendLine("RepeatLimit 200"); sb1.AppendLine("RewriteBase"); List <Lebi_Language> langs = B_Lebi_Language.GetList("", "Sort desc,id asc"); List <Lebi_Theme_Page> models = B_Lebi_Theme_Page.GetList("Type_id_PublishType=123", ""); string str1 = ""; string str2 = ""; string language = ""; foreach (Lebi_Theme_Page model in models) { if (model.PageParameter == "") { str1 = model.PageName; str2 = model.StaticPath + "/" + model.StaticPageName; str2 = ThemeUrl.CheckURL(str2); str1 = str1.Trim('/'); str2 = str2.Trim('/'); str1 = str1.Replace(".", @"\."); str2 = str2.Replace(".", @"\."); foreach (Lebi_Language lang in langs) { Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id); if (site == null) { site = new Lebi_Site(); } language = site.Path + lang.Path.TrimEnd('/'); language = language.Replace("//", "/"); if (language == "") { continue; } sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str1 + " [N,I]"); sb1.AppendLine(@"RewriteRule " + language + "/" + str2 + "(.*)$ " + language + "/" + str1 + " [NC,N]"); } sb.AppendLine(@"RewriteRule /(.*)" + str2 + "(.*) /$1" + str1 + " [N,I]"); sb1.AppendLine(@"RewriteRule /" + str2 + "(.*)$ /" + str1 + " [NC,N]"); //RewriteRule /CN/(.*)$ /CN/Basket\.aspx\?Basket\.html$1 [NC,N] //RewriteRule /(.*)$ /Basket\.aspx\?Basket\.html$1 [NC,N] } else { str1 = model.PageName + @"\?" + model.PageParameter; str2 = model.StaticPath + "/" + model.StaticPageName; str2 = ThemeUrl.CheckURL(str2); str1 = str1.Trim('/'); str2 = str2.Trim('/'); str1 = str1.Replace(".", @"\."); str2 = str2.Replace(".", @"\."); str1 = RegexTool.ReplaceRegValue(str1, @"{\d+}", ","); str2 = RegexTool.ReplaceRegValue(str2, @"{\d+}", "(.*)"); string[] arr = str1.Split(','); int j = 1; string str_ini = ""; string str_hta = ""; foreach (string ar in arr) { if (ar != "") { str_hta += ar + "$" + j; } j++; if (ar != "") { str_ini += ar + "$" + j; } } foreach (Lebi_Language lang in langs) { Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id); if (site == null) { site = new Lebi_Site(); } language = site.Path + lang.Path.TrimEnd('/'); language = language.Replace("//", "/"); if (language == "") { continue; } sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str_ini + " [N,I]"); sb1.AppendLine(@"RewriteRule " + language + "/" + str2 + "(.*)$ " + language + "/" + str_hta + " [NC,N]"); } sb.AppendLine(@"RewriteRule /(.*)" + str2 + "(.*) /$1" + str_ini + " [N,I]"); sb1.AppendLine(@"RewriteRule /" + str2 + "(.*)$ /" + str_hta + " [NC,N]"); } } //生成商品分类重写规则 List <Lebi_Pro_Type> tps = B_Lebi_Pro_Type.GetList("", ""); Lebi_Theme_Page tpage = B_Lebi_Theme_Page.GetModel("Code='P_ProductCategory'"); str1 = tpage.PageName + @"\?" + tpage.PageParameter; str1 = str1.Trim('/'); str1 = str1.Replace(".", @"\."); str1 = RegexTool.ReplaceRegValue(str1, @"{\d+}", ","); string[] arr1 = str1.Split(','); string str_ini1 = ""; string str_hta1 = ""; //foreach (string ar in arr1) //{ // if (ar != "") // str_hta1 += ar + "$" + j1; // j1++; // if (ar != "") // str_ini1 += ar + "$" + j1; //} foreach (Lebi_Pro_Type tp in tps) { str_hta1 = arr1[0] + tp.id; str_ini1 = arr1[0] + tp.id; foreach (Lebi_Language lang in langs) { if (Language.Content(tp.IsUrlrewrite, lang.Code) != "1") { continue; } str2 = Language.Content(tp.Url, lang.Code); if (str2 == "") { continue; } str2 = ThemeUrl.CheckURL(str2); str2 = str2.Trim('/'); str2 = str2.Replace(".", @"\."); str2 = RegexTool.ReplaceRegValue(str2, @"{\d+}", "(.*)"); Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id); if (site == null) { site = new Lebi_Site(); } language = site.Path + lang.Path.TrimEnd('/'); language = language.Replace("//", "/"); language = language.TrimEnd('/'); sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str_ini1 + " [N,I]"); sb1.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*)$ /$1" + language + "/" + str_hta1 + " [NC,N]"); } } HtmlEngine save = new HtmlEngine(); save.CreateFile("httpd.ini", sb.ToString(), "ascii"); save.CreateFile(".htaccess", sb1.ToString(), "ascii"); CreateURLRewrite_shop(); }
protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode) { LoadTheme(themecode, siteid, languagecode, pcode); id = Rint_Para("0"); //商品分类 pid = Rint_Para("1"); //品牌 cid = Rstring_Para("2"); //属性 list = Rstring_Para("3"); //列表或网格 sort = Rstring_Para("4"); //排序 tid = Rint_Para("5"); //商品标签 transport = Rint_Para("7"); //配送 0全部 1商城 2商家 stock = Rint_Para("8"); //是否有库存 1只显示有货 pageindex = RequestTool.RequestInt("page", 1); pro_type = B_Lebi_Pro_Type.GetModel(id); if (pro_type == null) { pro_type = new Lebi_Pro_Type(); } if (Lang(pro_type.Url) != "") //如果存在自定义URL 跳转至自定义URL by kingdge 2014-10-30 { Response.Redirect(Lang(pro_type.Url)); Response.End(); return; } property = EX_Product.ProductType_ProPerty(pro_type); if (property == null) { property = new Lebi_Pro_Type(); property.ProPerty132 = "0"; } if (property.ProPerty132 == "") { property.ProPerty132 = "0"; } path = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">»</em>"; if (pro_type.id > 0) { CategoryPath = Categorypath(id); for (int i = 0; i <= CategoryPath.GetUpperBound(0); i++) { path += "<a href=\"" + URL("P_ProductCategory", "" + CategoryPath[i, 0] + "", CategoryPath[i, 2]) + "\"><span>" + CategoryPath[i, 1] + "</span></a>"; if (i < CategoryPath.GetUpperBound(0)) { path += "<em>»</em>"; } } } else if (tid == 0) { path += "<a href=\"" + URL("P_ProductCategory", "0") + "\"><span>" + Tag("商品列表") + "</span></a>"; } if (tid > 0) { tag = B_Lebi_Pro_Tag.GetModel(tid); path += "<em>»</em><a href=\"" + URL("P_ProductCategory", "" + id + ",$,$,$,$," + tid + "") + "\"><span>" + Lang(tag.Name) + "</span></a>"; } where = ProductWhere + " and Type_id_ProductType <> 323"; if (pid > 0) { where += " and Brand_id=" + pid + ""; brand = B_Lebi_Brand.GetModel(pid); path += "<em>»</em><a href=\"" + URL("P_ProductCategory", "" + id + "," + pid + ",$,$,$,$") + "\"><span>" + Lang(brand.Name) + "</span></a>"; } if (cid != "") { where += " and " + Categorywhere(cid); string _cidlast = ""; if (cid.IndexOf("$") > -1) { string[] cidarr = cid.Split('$'); for (int i = 0; i < cidarr.Count(); i++) { if (cidarr[i].IndexOf("|") > -1) { string[] _cids = cidarr[i].Split('|'); _cidlast = _cids[1]; Lebi_ProPerty ProPerty = B_Lebi_ProPerty.GetModel(int.Parse(_cidlast)); if (ProPerty != null) { path += "<em>»</em><a href=\"" + URL("P_ProductCategory", "" + id + "," + pid + "," + ProPerty.parentid + "|" + ProPerty.id + ",$,$,$") + "\"><span>" + Lang(ProPerty.Name) + "</span></a>"; } } } } else { if (cid.IndexOf("|") > -1) { string[] _cids = cid.Split('|'); _cidlast = _cids[1]; Lebi_ProPerty ProPerty = B_Lebi_ProPerty.GetModel(int.Parse(_cidlast)); if (ProPerty != null) { path += "<em>»</em><a href=\"" + URL("P_ProductCategory", "" + id + "," + pid + "," + ProPerty.parentid + "|" + ProPerty.id + ",$,$,$") + "\"><span>" + Lang(ProPerty.Name) + "</span></a>"; } } } } if (id > 0) { where += " and " + CategoryWhere(id); //where += " and (Pro_Type_id in (" + Categorywhereforid(id) + ")"; //if (DataBase.DBType == "sqlserver") //{ // where += " or Charindex('," + id + ",',','+Pro_Type_id_other+',')>0)"; //} //if (DataBase.DBType == "access") //{ // where += " or Instr(','+Pro_Type_id_other+',','," + id + ",')>0)"; //} } if (tid > 0) { if (DataBase.DBType == "sqlserver") { where += " and Charindex('," + tid + ",',','+Pro_Tag_id+',')>0"; } if (DataBase.DBType == "access") { where += " and Instr(','+Pro_Tag_id+',','," + tid + ",')>0"; } } if (transport == 1) { where += " and IsSupplierTransport = 0"; } else if (transport == 2) { where += " and IsSupplierTransport = 1"; } if (stock == 1) { where += " and Count_Stock > 0"; } if (sort == "1") { order = " Count_Sales_Show desc"; ordertmp = "a"; } else if (sort == "1a") { order = " Count_Sales_Show asc"; ordertmp = ""; } else if (sort == "2") { order = " Price desc"; ordertmp = "a"; } else if (sort == "2a") { order = " Price asc"; ordertmp = ""; } else if (sort == "3") { order = " Count_Comment desc"; ordertmp = "a"; } else if (sort == "3a") { order = " Count_Comment asc"; ordertmp = ""; } else if (sort == "4") { order = " Time_Add desc"; ordertmp = "a"; } else if (sort == "4a") { order = " Time_Add asc"; ordertmp = ""; } else if (sort == "5") { order = " Count_Views_Show desc"; ordertmp = "a"; } else if (sort == "5a") { order = " Count_Views_Show asc"; ordertmp = ""; } else if (sort == "6") { order = " Count_Stock desc"; ordertmp = "a"; } else if (sort == "6a") { order = " Count_Stock asc"; ordertmp = ""; } else { order = " Sort desc,id desc"; ordertmp = ""; } products = B_Lebi_Product.GetList(where, order, PageSize, pageindex); recordCount = B_Lebi_Product.Counts(where); //id={0}&pid={1}&cid={2}&list={3}&sort={4}&tid={5}&page={6} string url = URL("P_ProductCategory", id + "," + pid + "," + cid + "," + list + "," + sort + "," + tid + ",{0}," + transport + "," + stock + "", Lang(pro_type.Url)); HeadPage = Shop.Bussiness.Pager.GetPaginationStringForWebSimple(url, pageindex, PageSize, recordCount, CurrentLanguage); FootPage = Shop.Bussiness.Pager.GetPaginationStringForWeb(url, pageindex, PageSize, recordCount, CurrentLanguage); }
/// <summary> /// 设置商品分类缓存 /// </summary> public static void SetProductType() { List <Lebi_Pro_Type> models = B_Lebi_Pro_Type.GetList("(IsDel!=1 or IsDel is null)", "Sort desc"); CacheTool.Permanent("ProductType", models); }
protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode) { LoadTheme(themecode, siteid, languagecode, pcode); CurrentPage = B_Lebi_Theme_Page.GetModel("Code='P_Product'"); int id = Rint_Para("0"); product = GetProduct(id); if (product.id == 0) { Response.Redirect(URL("P_404", "")); Response.End(); } int num = 0; if (SYS.ClickFlag == "0") { int.TryParse(SYS.ClickNum1, out num); product.Count_Views_Show = product.Count_Views_Show + num; } else { int.TryParse(SYS.ClickNum2, out num); Random r = new Random(); int c = r.Next(1, num); product.Count_Views_Show = product.Count_Views_Show + c; } product.Count_Views = product.Count_Views + 1; B_Lebi_Product.Update(product); Protype = B_Lebi_Pro_Type.GetModel(product.Pro_Type_id); images = EX_Product.ProductImages(product, CurrentTheme); //=============================================================== //处理规格选项 //ProductProperty = Get_guige(product); //处理规格选项结束 //================================================================== //添加访问记录 int Product_id = product.Product_id == 0 ? product.id : product.Product_id; EX_User.UserProduct_Edit(CurrentUser, Product_id, 0, 143, "", 0, ""); path = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">»</em>"; if (product.Type_id_ProductType == 321) { path += "<a href=\"" + URL("P_LimitBuy", "") + "\"><span>" + Tag("限时抢购") + "</span></a><em>»</em>"; } else if (product.Type_id_ProductType == 322) { path += "<a href=\"" + URL("P_GroupPurchase", "") + "\"><span>" + Tag("团购") + "</span></a><em>»</em>"; } else if (product.Type_id_ProductType == 323) { path += "<a href=\"" + URL("P_Exchange", "") + "\"><span>" + Tag("积分换购") + "</span></a><em>»</em>"; } else { if (Protype != null) { string[,] parr = Categorypath(Protype.id); for (int i = 0; i <= parr.GetUpperBound(0); i++) { path += "<a href=\"" + URL("P_ProductCategory", "" + parr[i, 0] + "") + "\"><span>" + parr[i, 1] + "</span></a><em>»</em>"; } } } path += "<a href=\"" + URL("P_Product", id) + "\"><span>" + Lang(product.Name) + "</span></a>"; GetProWords(); ProductStar = Convert.ToInt32(product.Star_Comment); if (ProductStar > 5) { ProductStar = 5; } if (ProductStar < 0) { ProductStar = 0; } }