Ejemplo n.º 1
0
        /// <summary>
        /// 读取导入列表文件
        /// </summary>
        /// <param name="path"></param>
        private void Read(string path)
        {
            StreamReader sr = new StreamReader(path, Encoding.Default);
            InportThreads.WareLength = sr.ReadToEnd().Split('\n').Length;
            if (sr.EndOfStream)
            {
				//重置文件指针至文件头
                sr.BaseStream.Seek(0, SeekOrigin.Begin);
            }
            String line;
            List<ProductInfo> wareList = new List<ProductInfo>();
            while ((line = sr.ReadLine()) != null)
            {
                _myProduct = WareService.GetInstance().GetWareInfo(line);
                if (_myProduct != null)
                {
                    wareList.Add(_myProduct);
                }
                InportThreads.WareStep++;
            }

            foreach (var item in wareList)
            {
                DBHelper.GetInstance().WareInsert(item);
                InportThreads.WareStep++;
            }

            InportThreads.WareEnd = true;
        }
Ejemplo n.º 2
0
 public FrmResInfo(ProductInfo pInfo)
 {
     InitializeComponent();
     _isEdit = true;
     _myProduct = pInfo;
     btnGet.Text = "最新信息";
     btnSave.Text = "更新商品";
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新商品信息
        /// </summary>
        /// <param name="_myProduct"></param>
        public void WareUpdate(ProductInfo _myProduct)
        {
            OtDB db = GetDb();
            try
            {
                db.Begin();
                db.ExecUpdate(_myProduct, "ProductInfo", new string[] {"ProductID", "ProductName", "ProductPrice","ProductIsSaled",
                    "ProductTag", "ProductBrand", "ProductAttach", "ProductType","ProductImagePath"}, string.Format(" ProductID = '{0}'", _myProduct.ProductID), null);
                db.Commit();

            }
            catch (Exception ex)
            {
                OtCom.XLogErr(ex.Message);
                db.Rollback();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 插入商品信息
 /// </summary>
 /// <param name="_myProduct"></param>
 public void WareInsert(ProductInfo _myProduct)
 {
     OtDB db = GetDb();
     try
     {
         db.Begin();
         db.ExecInsert(_myProduct, "ProductInfo", new string[] { "RID","ProductID", "ProductName", "ProductPrice","ProductIsSaled",
             "ProductEvaluateCount", "ProductGoodRate", "ProductImagePath", "ProductURL", "ProductDetail","ProductBrand",
             "ProductAttach","NativeData","CreateTime","CreateUser","BEnable" });
         db.Commit();
         
     }
     catch (Exception ex)
     {
         OtCom.XLogErr(ex.Message);
         db.Rollback();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新商品信息
 /// </summary>
 /// <param name="_myProduct"></param>
 public void WareUpdate(ProductInfo _myProduct)
 {
     OtDB db = GetDb();
     try
     {
         db.Begin();
         db.ExecUpdate(_myProduct, "ProductInfo", new string[] { "ProductName", "BrandID", "ProductBrand", "ProductAttach", "ProductIsSaled", 
             "ProductTag", "Catalog", "ProductImageWebPath",
              "ProductImagePath", "ProductURL","ProductCoupon", "ProductPromoMsg", "ProductDispatchMode",
              "ProductPrice", "ProductType", "ProductMobilePrice", "ProductQQPrice", "ProductWXPrice", //"ProductPriceTrend", "ProductBasePrice",
              "ProductGeneralRate", "ProductPoorRate", "ProductHotCommentTag", "ProductEvaluateCount", "ProductGoodRate", "Focus" },
               string.Format(" ProductID = '{0}'", _myProduct.ProductID), null);
         db.Commit();
     }
     catch (Exception ex)
     {
         OtCom.XLogErr(ex.Message);
         db.Rollback();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 新增商品信息
 /// </summary>
 /// <param name="_myProduct"></param>
 public void WareInsert(ProductInfo _myProduct)
 {
     OtDB db = GetDb();
     try
     {
         db.Begin();
         db.ExecInsert(_myProduct, "ProductInfo", new string[] { "RID", "ProductID", "SkuID", "SkuidKey", "VenderId", "ShopId", "ProductName", 
             "BrandID", "ProductBrand", "ProductAttach", "ProductIsSaled",  "ProductTag", "Catalog", "ProductImageWebPath",
              "ProductImagePath", "ProductURL","ProductCoupon", "ProductPromoMsg", "ProductDispatchMode",
              "ProductPrice", "ProductBasePrice","ProductMobilePrice","ProductQQPrice","ProductWXPrice", "ProductType", "ProductPriceTrend",
              "ProductGeneralRate", "ProductPoorRate", "ProductHotCommentTag", "ProductEvaluateCount", "ProductGoodRate", 
               "CreateTime", "CreateUser", "Focus", "BEnable" });
         db.Commit();
     }
     catch (Exception ex)
     {
         OtCom.XLogErr(ex.Message);
         db.Rollback();
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 导入商品
        /// </summary>
        /// <param name="webSites">商品地址数据</param>
        private void ImportWares(List<WebSiteModel> webSites)
        {
            try
            {
                //确定采集模式为批量采集
                SysParams.GatherModel = GatherType.Batch;
                _step = 0;
                ShowImportMessage("导入商品线程开始");
                List<ProductInfo> wareList = new List<ProductInfo>();
                ShowImportMessage("等待导入商品总数:" + webSites.Count.ToString());
                foreach (var item in webSites)
                {
                    string pid = Regex.Match(item.url, "\\d{1,14}").Value;
                    //如果商品编号已存在,则不导入
                    if (!string.IsNullOrEmpty(pid) && !DBHelper.GetInstance().WareIsExists(pid))
                    {
                        ImportThreads.WareID = pid;
                        ShowImportMessage("获取商品数据" + item.url);
                        _myProduct = WareService.GetInstance().GetWareInfo(item.url);
                        if (_myProduct != null)
                        {
                            wareList.Add(_myProduct);
                        }
                    }
                    else
                    {
                        ShowImportMessage("商品" + item.url + "已存在");
                    }
                    ShowImportStep(_step);
                    _step++;
                }
                ShowImportMessage("已获取商品总数:" + wareList.Count.ToString());

                foreach (var item in wareList)
                {
                    ShowImportMessage("导入商品数据" + item.ProductName);
                    DBHelper.GetInstance().WareInsert(item);
                    DBHelper.GetInstance().WarePriceInsert(item.ProductID, item.ProductPrice);
                    ShowImportStep(_step);
                    _step++;
                }
                while (_step <= webSites.Count * 2)
                {
                    _step++;
                    ShowImportStep(_step);
                }
                ShowImportMessage("导入商品线程结束");
                EndImportProcess(true);
            }
            catch (Exception ex)
            {
                EndImportProcess(false);
                ShowImportMessage("导入商品线程异常" + ex.Message);
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取手机专享价
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public double GetWareMobilePriceByID(string pid)
        {
            try
            {
                //PC https://p.3.cn/prices/mgets?type=1&skuIds=
                //APP https://pm.3.cn/prices/mgets?origin=2&skuids=
                //QQ https://pe.3.cn/prices/mgets?origin=4&skuids=
                //weixin https://pe.3.cn/prices/mgets?origin=5&skuids=
                //http://item.m.jd.com/ware/thirdAddress.json?checkParam=KKLLTL&wareId={0}&provinceId={1}&cityId={2}&countryId={3}&action=getTowns
                if (_myProduct == null)
                {
                    _myProduct = new ProductInfo();
                }
                double myPrice = 0;
                //商品价格 http://pm.3.cn/prices/pcpmgets?callback=jQuery3820568&skuids=202459&origin=2&source=1&area=1_2800_4134_0&_=1451370905656
                //jQuery5068505([{"id":"202459","pcp":"69.00","p":"59.00","m":"121.00"}]);

                //通过接口获取所有平台价格
                //http://p.3.cn/prices/mgets?type=1&skuIds=J_10221286883,J_2031542,J_1433346,J_1079888,J_2326463,J_1618201,J_1905327,J_10221540634&callback=jQuery6726231&_=1459406187522
                //string pcPrice = string.Format("https://p.3.cn/prices/mgets?type=1&skuIds=J_{0}", pid);
                //string pcPrice1 = HttpHelper.GetResponseGBK(pcPrice, "get", string.Empty).Replace("[","").Replace("]\n","");
                //JdWarePrice pcPrices = JsonConvert.DeserializeObject<JdWarePrice>(pcPrice1);
                //if (pcPrices != null)
                //{
                //    _myProduct.ProductPrice = double.Parse(pcPrices.p);
                //}

                string appPrice = string.Format("https://pm.3.cn/prices/mgets?origin=2&skuids={0}", pid);
                string appPrice1 = HttpHelper.GetResponseGBK(appPrice, "get", string.Empty).Replace("[", "").Replace("]\n", "");
                JdWarePrice appPrices = JsonConvert.DeserializeObject<JdWarePrice>(appPrice1);
                if (appPrices != null)
                {
                    _myProduct.ProductMobilePrice = double.Parse(appPrices.p);
                }

                string qqPrice = string.Format("https://pe.3.cn/prices/mgets?origin=4&skuids={0}", pid);
                string qqPrice1 = HttpHelper.GetResponseGBK(qqPrice, "get", string.Empty).Replace("[", "").Replace("]\n", "");
                JdWarePrice qqPrices = JsonConvert.DeserializeObject<JdWarePrice>(qqPrice1);
                if (qqPrices != null)
                {
                    _myProduct.ProductQQPrice = double.Parse(qqPrices.p);
                }

                string wxPrice = string.Format("https://pe.3.cn/prices/mgets?origin=5&skuids={0}", pid);
                string wxPrice1 = HttpHelper.GetResponseGBK(wxPrice, "get", string.Empty).Replace("[", "").Replace("]\n", "");
                JdWarePrice wxPrices = JsonConvert.DeserializeObject<JdWarePrice>(wxPrice1);
                if (wxPrices != null)
                {
                    _myProduct.ProductWXPrice = double.Parse(wxPrices.p);
                }
                //判断哪个价格最低,最低值作为返回值
                double minPrice = GetMinPrice(_myProduct.ProductPrice, _myProduct.ProductMobilePrice, _myProduct.ProductQQPrice, _myProduct.ProductWXPrice);
                //正常途径获取价格
                //用于验证价格数据
                string url_price = string.Format("http://pm.3.cn/prices/pcpmgets?callback=jQuery3820568&skuids={0}&origin=2&source=1&area=1_2800_4134_0&_=1451370905656", pid);
                string html_price = HttpHelper.GetResponseGBK(url_price, "get", string.Empty);
                if (string.IsNullOrEmpty(html_price))
                {
                    return 0;
                }
                string str_price = html_price.Replace("jQuery3820568([", "").Replace("]);", "");

                JdWareMobilePrice price = JsonConvert.DeserializeObject<JdWareMobilePrice>(str_price);
                myPrice = double.Parse(price.p);
                //规则:如果价格小于0,该商品下柜
                if (myPrice < 0)
                {
                    myPrice = 0;
                    _myProduct.ProductIsSaled = -1;
                    _myProduct.ProductStock = "下柜";
                }
                //if (!string.IsNullOrEmpty(price.pcp))
                //{
                //    _myProduct.ProductPriceType = "手机";
                //}
                _myProduct.ProductPrice = myPrice;

                return (myPrice == 0 ? 0 : minPrice);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return 0;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 获取商品页面具备信息
        /// </summary>
        /// <param name="url">访问网址</param>
        /// <param name="isNew">是否新商品</param>
        /// <returns></returns>
        private ProductInfo GetWareBaseInfo(string url, bool isNew)
        {
            try
            {
                string tID = Regex.Match(url, "\\d{1,14}").Value;
                string html = HttpHelper.GetResponseGBK(url, "get", string.Empty);
                if (string.IsNullOrEmpty(html))
                {
                    //MessageBox.Show("未找到商品!", "系统提示");
                    return null;
                }
                //获取商品名称
                //string ss = Regex.Match(html, @"<title>[^<]*</title>").Value;
                //Regex reg = new Regex("<title>(.*?)</title>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                string sRegexReturn = Regex.Match(html, @"\<title[^\>]*\>\s*(?<Title>.*?)\s*\</title\>").Value;
                if (sRegexReturn.IndexOf("京东(JD.COM)") >= 0)
                {
                    //MessageBox.Show("未找到编号为" + tID + "的商品!", "系统提示");
                    return null;
                }
                if (isNew)
                {
                    _myProduct = new ProductInfo();
                    _myProduct.RID = Guid.NewGuid().ToString();
                    _myProduct.ProductID = tID;
                    _myProduct.ProductURL = url;
                }
                _myProduct.NativeData = html;
                _myProduct.PageConfig = Regex.Match(html, @"var pageConfig = {\w*};").Value;

                //_myProduct.ProductName = GetTitleContent(sRegexReturn, "title").Replace(extTitle, "");
                _myProduct.ProductName = GetTitleContent(sRegexReturn);

                //获取商品库存情况
                string stock = Regex.Match(_myProduct.NativeData, @"<h3><strong>该商品已下柜,非常抱歉!</strong></h3>").Value;
                if (!string.IsNullOrEmpty(stock))
                {
                    _myProduct.ProductIsSaled = -1;
                    _myProduct.ProductStock = "下柜";
                }
                //TO-DO 暂无报价商品处理

                //获取商品归属类型 自营、旗舰店、第三方
                //根据商品编号取值不同来判断商品归属
                //自营 venderId:0 shopId:'0'
                //旗舰店 venderId:1000001624 shopId:'1000001624'
                //第三方 venderId:153108 shopId:'148186'
                //cat: [9855,9857,9908]
                //skuid: 202459,
                //skuidkey:'F7057726EEDA872B4FF09D080FB941D5',
                //brand: 18374,
                //\s* 任意空白字符(可能是0次) \s+ 匹配重复1次或更多次
                string skuId = Regex.Match(html, @"skuid:\s*(\d{1,14})").Value.Replace("skuid:", "").Trim();
                string skuidKey = Regex.Match(html, @"skuidkey:\s*'\w*'").Value.Replace("skuidkey:", "").Trim().Replace("'","");
                string venderId = Regex.Match(html, "venderId:(\\d{1,14})").Value.Replace("venderId:", "");
                string shopId = Regex.Match(html, "shopId:'(\\d{1,14})'").Value.Replace("shopId:'", "").TrimEnd('\'');
                if (string.IsNullOrEmpty(shopId))
                {
                    shopId = Regex.Match(html, @"shopId:(\d{1,14})").Value.Replace("shopId:", "");
                }
                string cat = Regex.Match(html, @"cat: \[(\d{1,5}),(\d{1,5}),(\d{1,5})\]").Value.Replace("cat: [", "").TrimEnd(']');
                string brandid = Regex.Match(html, @"brand:\s*(\d{1,10})").Value.Replace("brand:", "").Trim();
                if (!string.IsNullOrEmpty(venderId))
                {
                    _myProduct.ProductAttach = venderId != shopId ? "第三方" : venderId == "0" ? "自营" : "旗舰店";
                    _myProduct.SkuID = skuId;
                    _myProduct.SkuidKey = skuidKey;
                    _myProduct.ShopId = shopId;
                    _myProduct.VenderId = venderId;
                    _myProduct.Catalog = cat; 
                    _myProduct.BrandID = brandid;
                }
                return _myProduct;
            }
            catch (Exception ex)
            {
                OtCom.XLogErr(ex.Message);
                return null;
            }

        }
Ejemplo n.º 10
0
        /// <summary>
        /// 批价格解析
        /// </summary>
        /// <param name="url">访问网址</param>
        /// <param name="src">价格来源</param>
        private void BatchParse(string url, WarePriceType src)
        {
            try
            {
                string price = HttpHelper.GetResponseGBK(url, "get", string.Empty);
                if (string.IsNullOrEmpty(price) || price.IndexOf("error") >= 0)
                {

                    //获取价格失败则退出
                    return;
                }

                //网页价格
                List<JdWarePrice> jdPrices = JsonConvert.DeserializeObject<List<JdWarePrice>>(price);
                if (jdPrices != null && jdPrices.Count > 0)
                {
                    foreach (var item in jdPrices)
                    {
                        string pid = item.id.IndexOf('J') >= 0 ? item.id.Replace("J_","") : item.id;
                        ProductInfo tmpWare = _wares4Batch.Find(t => t.ProductID == pid);
                        if (tmpWare == null)
                        {
                            tmpWare = new ProductInfo();
                            tmpWare.ProductID = pid;
                            _wares4Batch.Add(tmpWare);
                        }

                        switch (src)
                        {
                            case WarePriceType.WebPrice:
                                tmpWare.ProductPrice = double.Parse(item.p);
                                break;
                            case WarePriceType.AppPrice:
                                tmpWare.ProductMobilePrice = double.Parse(item.p);
                                break;
                            case WarePriceType.QQPrice:
                                tmpWare.ProductQQPrice = double.Parse(item.p);
                                break;
                            case WarePriceType.WxPrice:
                                tmpWare.ProductWXPrice = double.Parse(item.p);
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                OtCom.XLogErr(ex.Message);
            }
            
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 重载图片
        /// </summary>
        /// <param name="ProductInfo">产品对象</param>
        /// <param name="isSaveToDB">是否入库</param>
        public void ReloadImg(ProductInfo myInfo, bool isSaveToDB)
        {
            try
            {
                _myProduct = myInfo;
                if (string.IsNullOrEmpty(myInfo.ProductImageWebPath))
                {
                    string url = string.Format("http://item.jd.com/{0}.html", myInfo.ProductID);

                    string tID = Regex.Match(url, "\\d{1,14}").Value;
                    string html = HttpHelper.GetResponseGBK(url, "get", string.Empty);
                    if (string.IsNullOrEmpty(html))
                    {
                        return;
                    }
                    //获取商品名称
                    string sRegexReturn = Regex.Match(html, @"\<title[^\>]*\>\s*(?<Title>.*?)\s*\</title\>").Value;
                    if (sRegexReturn.IndexOf("京东(JD.COM)") >= 0)
                    {
                        //MessageBox.Show("未找到编号为" + tID + "的商品!", "系统提示");
                        return;
                    }

                    //获取图片路径
                    sRegexReturn = GetImgPath(html);
                    if (!string.IsNullOrEmpty(sRegexReturn))
                    {
                        myInfo.ProductImagePath = sRegexReturn;
                        myInfo.ProductImageWebPath = sRegexReturn;
                    }
                }

                Bitmap img = GetRemoteImage(myInfo.ProductImageWebPath);
                if (img != null)
                {
                    myInfo.ProductImage = img;
                    if (isSaveToDB)
                    {
                        DBHelper.GetInstance().WareImageUpdate(myInfo.ProductID, myInfo.ProductImagePath, myInfo.ProductImageWebPath);
                    }
                }
                else
                {
                    myInfo.ProductImage = img;
                }


            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

        }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取服务信息
        /// </summary>
        /// <param name="tID">商品编号</param>
        /// <param name="venderId">供应商编号</param>
        /// <param name="cat">配送区域</param>
        /// <returns>库存标记</returns>
        private int GetWareService(string tID, string venderId, string cat,string dispatch)
        {
            try
            {
                string stock = Regex.Match(_myProduct.NativeData, @"<h3><strong>该商品已下柜,非常抱歉!</strong></h3>").Value;
                if (!string.IsNullOrEmpty(stock))
                {
                    _myProduct.ProductIsSaled = -1;
                    _myProduct.ProductStock = "下柜";
                    return -1;
                }
                //配送服务 22_1930_4283_0
                if (string.IsNullOrEmpty(cat))
                {
                    cat = "6144,12041,12047";
                }
                //http://c0.3.cn/stock?skuId=1700908129&venderId=32533&cat=6144,12041,12047&area=1_72_2799_0&buyNum=1&extraParam={%22originid%22:%221%22}&ch=1&callback=getStockCallback
                //http://c0.3.cn/stock?skuId=852431&venderId=1000000248&cat=670,686,690&area=1_72_2799_0&buyNum=1&extraParam={"originid":"1"}&ch=1&callback=getStockCallback 
                //string url_service = "http://c0.3.cn/stock?skuId=" + tID + "&venderId=" + venderId.Trim() + "&cat=" + cat + "&area=" + dispatch 
                //    + "&buyNum=1&extraParam={%22originid%22:%221%22}&ch=1&callback=getStockCallback";

                string url_service = "http://c0.3.cn/stock?skuId=" + tID + "&venderId=" + venderId.Trim() + "&cat=" + cat + "&area=" + dispatch
                    + "&buyNum=1&extraParam={%22originid%22:%221%22}&ch=1";

                string html_service = HttpHelper.GetResponseGBK(url_service, "get", string.Empty);
                string str_stock = html_service.Replace("getStockCallback(", "").TrimEnd(')');
                if (string.IsNullOrEmpty(str_stock))
                {
                    return  -1;
                }
                StockInfo jdStock = JsonConvert.DeserializeObject<StockInfo>(str_stock);

                if (_myProduct == null)
                {
                    _myProduct = new ProductInfo();
                }
                _myProduct.ProductDispatchMode = ClearHtml(jdStock.Stock.serviceInfo);
                _myProduct.ProductBrand = string.IsNullOrEmpty(jdStock.Stock.self_D.deliver) ? jdStock.Stock.D.deliver : jdStock.Stock.self_D.deliver;
                //-1 下柜 0 无货 1 有货 2 配货 3 预订
                //33 有货(1), 40 可配货(2), 36 预订(3), 34 无货(0), 下柜(-1)
                _myProduct.ProductIsSaled = jdStock.Stock.StockState == 33 ? 1 : (jdStock.Stock.StockState == 40 ? 2 : (jdStock.Stock.StockState == 36 ? 3 : 0)); 
                _myProduct.ProductStock = jdStock.Stock.StockStateName;
                //品牌
                //string _service = Regex.Match(html_service, "\"deliver\":\"\\w*\"").Value.Replace("\"deliver\":\"", "").TrimEnd('\"');
                ////付款方式
                //string warePay = Regex.Match(html_service, "\"iconSrc\":\"\\w*\"").Value.Replace("\"iconSrc\":\"", "").TrimEnd('\"');
                ////库存情况
                //string wareAvailable = Regex.Match(html_service, "\"StockStateName\":\"\\w*\"").Value.Replace("\"StockStateName\":\"", "").TrimEnd('\"');

                //_myProduct.ProductDispatchMode = warePay;
                //_myProduct.ProductIsSaled = wareAvailable.IndexOf("现货") >= 0;
                //_myProduct.ProductStock = wareAvailable;

                return _myProduct.ProductIsSaled;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                //-1代表已下柜
                _myProduct.ProductIsSaled = -1;
                return -1;
            }

        }
Ejemplo n.º 13
0
        /// <summary>
        /// 更新商品信息
        /// </summary>
        /// <param name="ware">商品对象</param>
        public void UpdateWareinfo(ProductInfo ware)
        {
            if (ware != null)
            {
                _myProduct = ware;
                //获取页面最新信息
                GetWareBaseInfo(ware.ProductURL, false);
                //如果店铺编号或厂商编号为空则不处理
                if (string.IsNullOrEmpty(ware.VenderId) || string.IsNullOrEmpty(ware.ShopId))
                {
                    //更新商品异常信息(前期可能未获取的数据)
                    DBHelper.GetInstance().WareShopUpdate(_myProduct.ProductID, _myProduct.VenderId, _myProduct.ShopId, _myProduct.Catalog);
                    //return;
                }
                //下柜商品自动进入回收站
                if (_myProduct.ProductStock == "下柜" && SysParams.AllowAutoGC)
                {
                    DBHelper.GetInstance().WareDelOne(_myProduct.ProductID);
                    return;
                }

                //判断是否更新商品库存信息
                if (_myProduct.ProductStock != "下柜" && SysParams.AllowGetStock)
                {
                    //获取库存情况
                    int sale = GetWareService(_myProduct.ProductID, _myProduct.VenderId, _myProduct.Catalog, SysParams.DispathArea);
                    //如果库存为下柜状态,则商品价格为0
                    if (sale == -1)
                    {
                        DBHelper.GetInstance().WareRepositoryUpdate(_myProduct.ProductID, 0, 0, 0, 0, "", -1);
                        return;
                    }
                    else
                    {
                        DBHelper.GetInstance().WareRepositoryUpdate(_myProduct.ProductID, _myProduct.ProductDispatchMode);
                    }
                }

                //判断是否更新商品价格信息
                if (_myProduct.ProductStock != "下柜" && SysParams.AllowGetPrice)
                {
                    //获取商品价格
                    double rtnPrice = GetWarePriceByID(_myProduct.ProductID);
                    if (rtnPrice > 0)
                    {
                        DBHelper.GetInstance().WarePriceInsert(_myProduct.ProductID, rtnPrice, DateTime.Now, _myProduct.ProductPriceType);
                        DBHelper.GetInstance().WareRepositoryUpdate(_myProduct.ProductID, rtnPrice, _myProduct.ProductMobilePrice, _myProduct.ProductQQPrice,
                            _myProduct.ProductWXPrice, _myProduct.ProductPriceType, _myProduct.ProductIsSaled);
                        DBHelper.GetInstance().UpdateHistoryPriceBasebyID(_myProduct.ProductID);
                    }
                }
                
                if (_myProduct.ProductStock != "下柜" && SysParams.AllowGetPostMessage)
                {
                    //获取评价统计信息
                    GetEvaluateMsg(_myProduct.ProductID, false);
                    DBHelper.GetInstance().WareMessageUpdate(_myProduct.ProductID, _myProduct.ProductEvaluateCount, _myProduct.ProductGoodRate, 
                        _myProduct.ProductGeneralRate, _myProduct.ProductPoorRate, _myProduct.ProductHotCommentTag);
                }

                if (_myProduct.ProductStock != "下柜" && (SysParams.AllowGetPromo || SysParams.AllowGetCoupon))
                {
                    //获取促销信息
                    GetWarePromotion(_myProduct.ProductID, _myProduct.VenderId, _myProduct.ShopId, SysParams.DispathArea, _myProduct.Catalog);
                    DBHelper.GetInstance().WarePromotionUpdate(_myProduct.ProductID, _myProduct.ProductTag, _myProduct.ProductPromoMsg, _myProduct.ProductCoupon);
                }
                
            }


        }
Ejemplo n.º 14
0
 private void RemoveWare(ProductInfo item)
 {
     if (MessageBox.Show("回收站商品删除后无法恢复!是否继续删除?", "系统警告", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
         DBHelper.GetInstance().WareRemoveOne(item.ProductID);
         try
         {
             //删除商品图片
             string imgPath = Path.Combine(Environment.CurrentDirectory, item.ProductImagePath);
             if (File.Exists(imgPath))
             {
                 File.Delete(imgPath);
             }
         }
         catch (Exception ex)
         {
             Debug.WriteLine(ex.Message);
         }
     }
 }
Ejemplo n.º 15
0
        private void btnGet_Click(object sender, EventArgs e)
        {
            try
            {
                //pageInfo.Controls.Add(progressPanel1);
                //progressPanel1.BringToFront();
                //progressPanel1.Show();
                string tID = string.IsNullOrEmpty(txtID.Text) ? "1010527324" : txtID.Text.Trim();
                SysParams.GatherModel = GatherType.Single;
                ProductInfo tmpWare = WareDealer.WareService.GetInstance().GetWareInfoByID(tID); 
                if (_isEdit)
                {
                    //如果是浏览/编辑状态,历史低价、价格趋势不变
                    tmpWare.ProductBasePrice = _myProduct.ProductBasePrice;
                    tmpWare.ProductPriceTrend = _myProduct.ProductPriceTrend;
                }
                _myProduct = tmpWare;
                

                SetUIControls();
                
            }
            catch (Exception ex)
            {
                OtCom.XLogErr(ex.Message);
            }
            finally
            {
                //progressPanel1.Hide();
            }

        }
Ejemplo n.º 16
0
 /// <summary>
 /// 上一个商品
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnTop_Click(object sender, EventArgs e)
 {
     if (_myProduct != null && PubClass.GetInstance().CurWares != null && PubClass.GetInstance().CurWares.Count > 0)
     {
         int index = PubClass.GetInstance().CurWares.FindIndex(t => t.ProductID == _myProduct.ProductID);
         if (index >= 0)
         {
             index --;
             if (index < 0)
             {
                 index = PubClass.GetInstance().CurWares.Count - 1;
             }
             ShowMyProduct(index);
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(txtID.Text))
         {
             _myProduct = DBHelper.GetInstance().WareGetOne(txtID.Text);
         }
         
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 根据查询结果显示商品
 /// </summary>
 /// <param name="index"></param>
 private void ShowMyProduct(int index)
 {
     ProductInfo tmpProduct = PubClass.GetInstance().CurWares[index];
     _myProduct = DBHelper.GetInstance().WareGetOne(tmpProduct.ProductID);
     if (_myProduct != null)
     {
         InitUiControlsData();
     }
     else
     {
         MessageBox.Show("提取商品信息失败,请与杀京东开发商WolfStudio工作室联系!", "系统提示");
     }
 }