private void Reset_Count_Sales() { List <Lebi_Product> parents = B_Lebi_Product.GetList("Product_id = 0 and Type_id_ProductStatus = 101", ""); foreach (Lebi_Product parent in parents) { int total_count = 0; List <Lebi_Product> pros = B_Lebi_Product.GetList("Product_id = " + parent.id + " and Type_id_ProductStatus = 101", ""); if (pros.Count > 0) { foreach (Lebi_Product pro in pros) { string count_ = Common.GetValue("select sum(Count_Shipped) from Lebi_Order_Product where Product_id = " + pro.id + " and Order_id in(select Lebi_Order.id from Lebi_Order where Lebi_Order_Product.Order_id = Lebi_Order.id and Lebi_Order.Type_id_OrderType=211 and Lebi_Order.IsCompleted = 1)"); int count = 0; int.TryParse(count_, out count); pro.Count_Sales = count; B_Lebi_Product.Update(pro); total_count += count; parent.Count_Sales = total_count; } } else { string count_ = Common.GetValue("select sum(Count_Shipped) from Lebi_Order_Product where Product_id = " + parent.id + " and Order_id in(select Lebi_Order.id from Lebi_Order where Lebi_Order_Product.Order_id = Lebi_Order.id and Lebi_Order.Type_id_OrderType=211 and Lebi_Order.IsCompleted = 1)"); int count = 0; int.TryParse(count_, out count); parent.Count_Sales = count; } B_Lebi_Product.Update(parent); } }
/// <summary> /// 同步库存 /// </summary> public void mUpdateStock() { //mType 请求类别,同步库存时,该值为“mUpdateStock”。 //GoodsNO 货品编号 //BarCode 货品条码(主条码) //Stock 库存量 string GoodsNO = RequestTool.RequestString("GoodsNO"); int Stock = RequestTool.RequestInt("Stock"); string res = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; Lebi_Product product = B_Lebi_Product.GetModel("Number=lbsql{'" + GoodsNO + "'}"); if (product == null) { res += "<rsp><result>0</result><cause>无此商品</cause></rsp>"; Response.Write(res); } product.Count_Stock = Stock; B_Lebi_Product.Update(product); if (product.Product_id > 0) { //子商品库存变更,修改父商品库存 Lebi_Product model = B_Lebi_Product.GetModel(product.Product_id); if (model != null) { List <Lebi_Product> pros = B_Lebi_Product.GetList("Product_id=" + model.id + "", ""); int count = 0; foreach (Lebi_Product pro in pros) { count = count + pro.Count_Stock; } model.Count_Stock = count; B_Lebi_Product.Update(model); } } res += "<rsp><result>1</result></rsp>"; Log.Add("商品编码:" + GoodsNO + "数量:" + Stock + "--" + res, "网店管家同步库存", ""); Response.Write(res); }
/// <summary> /// 导入淘宝商品数据 /// </summary> public void taobao_product_in() { if (!Power("supplier_product_datainout", "导入导出")) { AjaxNoPower(); return; } int tb_typeid = RequestTool.RequestInt("tb_typeid", 0); string tb_file = RequestTool.RequestString("tb_file"); string tb_folder = RequestTool.RequestString("tb_folder"); string fileName = HttpContext.Current.Server.MapPath(@"~/" + WebPath + tb_file); int tb_split = RequestTool.RequestInt("tb_split", 0); string tbin_lang = RequestTool.RequestString("tbin_lang"); int i = 0; if (File.Exists(fileName)) { DataTable dt = new DataTable(); char flag = '\t'; if (tb_split == 2) { flag = ','; } using (FileStream fs = new FileStream(fileName, FileMode.Open)) { using (StreamReader reader = new StreamReader(fs, Encoding.Default)) { string text = string.Empty; while (!reader.EndOfStream) { text = reader.ReadLine(); if (i == 1) { string[] arr = text.Split(flag); foreach (string col in arr) { dt.Columns.Add(col); } } else if (i > 1) { string[] arr = text.Split(flag); DataRow r = dt.NewRow(); int j = 0; foreach (string col in arr) { if (j >= dt.Columns.Count) { break; } try { r[j] = col.Replace("\"", ""); } catch { r[j] = ""; } j++; } dt.Rows.Add(r); } i++; } } } //====================================== if (!dt.Columns.Contains("outer_id")) { Response.Write("{\"msg\":\"请检查是否包含outer_id字段\"}"); return; } string number = ""; int count = 0; for (int m = 0; m < dt.Rows.Count; m++) { try { if (dt.Columns.Contains("outer_id")) { number = dt.Rows[m]["outer_id"].ToString(); } bool addflag = false; Lebi_Product pro = B_Lebi_Product.GetModel("Supplier_id =" + CurrentSupplier.id + " and Number=lbsql{'" + number + "'}"); if (pro == null) { pro = new Lebi_Product(); addflag = true; pro.Number = dt.Rows[m]["outer_id"].ToString(); pro.Type_id_ProductStatus = 101; pro.Type_id_ProductType = 320; pro.Supplier_id = CurrentSupplier.id; pro.IsSupplierTransport = CurrentSupplierGroup.IsSubmit; } pro.Pro_Type_id = tb_typeid; if (dt.Columns.Contains("title")) { pro.Name = Language.GetString(dt.Rows[m]["title"].ToString(), pro.Name, tbin_lang); } if (dt.Columns.Contains("description")) { pro.Description = Language.GetString(dt.Rows[m]["description"].ToString(), pro.Description, tbin_lang); } if (dt.Columns.Contains("wireless_desc")) { pro.MobileDescription = Language.GetString(dt.Rows[m]["wireless_desc"].ToString(), pro.MobileDescription, tbin_lang); } if (dt.Columns.Contains("price")) { if (dt.Columns.Contains("price")) { string p = dt.Rows[m]["price"].ToString(); pro.Price = Convert.ToDecimal(p); } pro.Price_Market = pro.Price; pro.Price_Cost = pro.Price; } if (dt.Columns.Contains("num")) { int Count_Stock = 0; int.TryParse(Convert.ToString(dt.Rows[m]["num"]), out Count_Stock); pro.Count_Stock = Count_Stock; } if (dt.Columns.Contains("item_weight")) { int Weight = 0; int.TryParse(Convert.ToString(dt.Rows[m]["item_weight"]), out Weight); pro.Weight = Weight; } if (dt.Columns.Contains("VolumeL")) { int VolumeL = 0; int.TryParse(Convert.ToString(dt.Rows[m]["VolumeL"]), out VolumeL); pro.VolumeL = VolumeL; } if (dt.Columns.Contains("VolumeW")) { int VolumeW = 0; int.TryParse(Convert.ToString(dt.Rows[m]["VolumeW"]), out VolumeW); pro.VolumeW = VolumeW; } if (dt.Columns.Contains("VolumeH")) { int VolumeH = 0; int.TryParse(Convert.ToString(dt.Rows[m]["VolumeH"]), out VolumeH); pro.VolumeH = VolumeH; } if (dt.Columns.Contains("PackageRate")) { int PackageRate = 1; int.TryParse(Convert.ToString(dt.Rows[m]["PackageRate"]), out PackageRate); pro.PackageRate = PackageRate; } if (addflag) { B_Lebi_Product.Add(pro); pro.id = B_Lebi_Product.GetMaxId(); } else { B_Lebi_Product.Update(pro); } if (dt.Columns.Contains("picture")) { try { string img = dt.Rows[m]["picture"].ToString(); string images = ""; if (tb_folder == "") { //1f6edf58105f3abb1ef9665129eb6c52 //1f6edf58105f3abb1ef9665129eb6c52:1:0:|http://img01.taobaocdn.com/bao/uploaded/i1/T1Oys1FgNeXXXXXXXX_!!0-item_pic.jpg; //5327022ebfe958090d3abff999c8c800:1:1:|http://img02.taobaocdn.com/bao/uploaded/i2/24197542/T2wnCFXtNXXXXXXXXX_!!24197542.jpg; //b7972e16753d746d77f2f769002268d5:1:2:|http://img01.taobaocdn.com/bao/uploaded/i1/24197542/T2n6BuXvhXXXXXXXXX_!!24197542.jpg; //06e5fd8cdb3babd4664b7b736258290a:1:3:|http://img03.taobaocdn.com/bao/uploaded/i3/24197542/T2yX1BXwhXXXXXXXXX_!!24197542.jpg; //d1a5c9c441a994310db75a83005628b7:1:4:|http://img03.taobaocdn.com/bao/uploaded/i3/24197542/T2I4XAXpJaXXXXXXXX_!!24197542.jpg; //处理图片 string[,] arr = RegexTool.GetRegArray(img, @"\|(.*?);"); for (int ai = 0; ai < arr.GetUpperBound(0); ai++) { string v = RegexTool.GetRegValue(arr[ai, 1], @"\|(.*?);"); if (v == null || v == "") { continue; } LBimage lbimg = ImageHelper.DownLoadImage(v, pro); if (ai == 0) { pro.ImageBig = lbimg.big; pro.ImageMedium = lbimg.medium; pro.ImageOriginal = lbimg.original; pro.ImageSmall = lbimg.small; } else { images += "@" + lbimg.original; } } } else { //上传文件夹导入图片的方式 img = ";" + img; string[,] arr = RegexTool.GetRegArray(img, @";(.*?):"); string ServerPath = System.Web.HttpContext.Current.Server.MapPath("~/"); for (int ai = 0; ai < arr.GetUpperBound(0); ai++) { string v = RegexTool.GetRegValue(arr[ai, 1], @";(.*?):"); if (v == null || v == "") { continue; } v = ServerPath + tb_folder + "/" + v + ".tbi"; v = v.Replace("//", "/"); LBimage lbimg = ImageHelper.CreateTaobaoImage(v, pro); if (ai == 0) { pro.ImageBig = lbimg.big; pro.ImageMedium = lbimg.medium; pro.ImageOriginal = lbimg.original; pro.ImageSmall = lbimg.small; } else { images += "@" + lbimg.original; } } } pro.Images = images; B_Lebi_Product.Update(pro); } catch { } } count++; } catch { continue; } } Log.Add("导入淘宝商品", "Product", ""); Response.Write("{\"msg\":\"OK\",\"count\":\"" + count + "\"}"); } else { Response.Write("{\"msg\":\"" + Tag("数据文件错误") + "\"}"); return; } }
protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode) { pageindex = RequestTool.RequestInt("page", 1); 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); if (product.Product_id > 0) { string sql = "update [Lebi_Product] set Count_Views=Count_Views+1 where Product_id=" + product.Product_id + ""; Common.ExecuteSql(sql); } int DT_id = ShopPage.GetDT(); if (DT_id > 0) { string sql = "update [Lebi_DT_Product] set Count_Views=Count_Views+1 where DT_id = " + DT_id + " and Product_id=" + id + ""; Common.ExecuteSql(sql); if (product.Product_id > 0) { Common.ExecuteSql("update [Lebi_DT_Product] set Count_Views=Count_Views+1 where DT_id = " + DT_id + " and Product_id=" + product.Product_id + ""); } } 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, 1, 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; } }