Ejemplo n.º 1
0
        public void WarePriceUpdate(string pid, double price, WarePriceType priceSrc)
        {
            OtDB db = GetDb();

            try
            {
                string sql = "";
                switch (priceSrc)
                {
                case WarePriceType.WebPrice:
                    sql = string.Format("update ProductInfo set ProductPrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                    break;

                case WarePriceType.AppPrice:
                    sql = string.Format("update ProductInfo set ProductMobilePrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                    break;

                case WarePriceType.QQPrice:
                    sql = string.Format("update ProductInfo set ProductQQPrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                    break;

                case WarePriceType.WxPrice:
                    sql = string.Format("update ProductInfo set ProductWXPrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                    break;

                default:
                    break;
                }
                if (string.IsNullOrEmpty(sql))
                {
                    return;
                }
                db.Begin();
                db.Exec(sql);
                db.Commit();
            }
            catch (Exception ex)
            {
                OtCom.XLogErr(ex.Message);
                db.Rollback();
            }
        }
Ejemplo n.º 2
0
 public void WarePriceUpdate(string pid, double price, WarePriceType priceSrc)
 {
     OtDB db = GetDb();
     try
     {
         string sql = "";
         switch (priceSrc)
         {
             case WarePriceType.WebPrice:
                 sql = string.Format("update ProductInfo set ProductPrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                 break;
             case WarePriceType.AppPrice:
                 sql = string.Format("update ProductInfo set ProductMobilePrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                 break;
             case WarePriceType.QQPrice:
                 sql = string.Format("update ProductInfo set ProductQQPrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                 break;
             case WarePriceType.WxPrice:
                 sql = string.Format("update ProductInfo set ProductWXPrice = {0},ProductPriceDate = DateTime('now') where ProductID = '{1}';", price, pid);
                 break;
             default:
                 break;
         }
         if (string.IsNullOrEmpty(sql))
         {
             return;
         }
         db.Begin();
         db.Exec(sql);
         db.Commit();
     }
     catch (Exception ex)
     {
         OtCom.XLogErr(ex.Message);
         db.Rollback();
     }
 }
Ejemplo n.º 3
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);
            }
            
        }