Ejemplo n.º 1
0
        private object GetList(string json)
        {
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();
            HashObject           hash       = (HashObject)serializer.DeserializeObject(json);

            string[] keys =
            {
                "mods/itemlist/data/auctions"
            };
            var newHash = hash.GetHashValue(keys);

            if (newHash.Count == 0)
            {
                throw new Exception("没搜索到东西");
            }
            Object[]            array = (Object[])newHash[0]["auctions"];
            List <GoodsAddress> list  = new List <GoodsAddress>();

            foreach (HashObject item in array)
            {
                GoodsAddress test = new GoodsAddress();
                test.view_price = item.GetValue <string>("view_price", "");
                test.title      = item.GetValue <string>("title", "");
                test.nick       = item.GetValue <string>("nick", "");
                test.pic_url    = item.GetValue <string>("pic_url", "");
                test.detail_url = item.GetValue <string>("detail_url", "");
                test.view_sales = item.GetValue <string>("view_sales", "");
                list.Add(test);
            }
            return(list);
        }
Ejemplo n.º 2
0
        private DataTable GetMainData(string content)
        {
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();
            HashObject           hash       = serializer.Deserialize <HashObject>(content);

            string[] keys =
            {
                "mods/itemlist/data/auctions"
            };
            var       list     = hash.GetHashValue(keys);
            var       auctions = list[0].GetValue <ArrayList>("auctions");
            DataTable table    = CreateGoodsTable();

            foreach (HashObject obj in auctions)
            {
                DataRow row = table.NewRow();
                row["title"]      = obj.GetValue <string>("title");
                row["raw_title"]  = obj.GetValue <string>("raw_title");
                row["pic_url"]    = obj.GetValue <string>("pic_url");
                row["detail_url"] = obj.GetValue <string>("detail_url");
                row["item_loc"]   = obj.GetValue <string>("item_loc");
                string sales = obj.GetValue <string>("view_sales");
                row["view_sales"] = decimal.Parse(sales.Substring(0, sales.Length - 3));
                row["nick"]       = obj.GetValue <string>("nick");
                row["view_price"] = obj.GetValue <string>("view_price");
                row["view_fee"]   = obj.GetValue <string>("view_fee");
                table.Rows.Add(row);
            }
            return(table);
        }
Ejemplo n.º 3
0
        private List <SkuMap> GetSkumapTmallDetail(HashObject data)
        {
            List <SkuMap> list = new List <SkuMap>();

            string[] keys =
            {
                "valItemInfo/skuList",
                "valItemInfo/skuMap"
            };
            var skuList = data.GetHashValue(keys);
            var details = skuList.GetDataEx <ArrayList>("skuList");
            var skuMaps = skuList.GetDataEx <HashObject>("skuMap");

            foreach (HashObject hash in details)
            {
                SkuMap skuMap = new SkuMap();
                skuMap.Title = hash.GetValue <string>("names");
                skuMap.SkuId = hash.GetValue <string>("skuId");
                skuMap.Key   = string.Format(";{0};", hash.GetValue <string>("pvs"));
                var map = (HashObject)skuMaps[skuMap.Key];
                skuMap.Stock         = map.GetValue <decimal>("stock");
                skuMap.OriginalPrice = map.GetValue <decimal>("price");
                list.Add(skuMap);
            }

            return(list);
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                using (Stream stream = openFileDialog1.OpenFile())
                {
                    StreamReader reader = new StreamReader(stream);
                    string       text   = reader.ReadToEnd();
                    textBox1.Text = text;
                }
            }

            string content = textBox1.Text;
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();
            HashObject           hash       = serializer.Deserialize <HashObject>(content);

            string[] keys =
            {
                "mods/itemlist/data/auctions"
            };
            var       list     = hash.GetHashValue(keys);
            var       auctions = list[0].GetValue <ArrayList>("auctions");
            DataTable table    = new DataTable();

            table.Columns.Add("title");
            table.Columns.Add("raw_title");
            table.Columns.Add("pic_url");
            table.Columns.Add("detail_url");
            table.Columns.Add("item_loc");
            table.Columns.Add("view_sales", typeof(decimal));
            table.Columns.Add("nick");
            table.Columns.Add("content");

            foreach (HashObject obj in auctions)
            {
                DataRow row = table.NewRow();
                row["title"]      = obj.GetValue <string>("title");
                row["raw_title"]  = obj.GetValue <string>("raw_title");
                row["pic_url"]    = obj.GetValue <string>("pic_url");
                row["detail_url"] = obj.GetValue <string>("detail_url");
                row["item_loc"]   = obj.GetValue <string>("item_loc");
                string sales = obj.GetValue <string>("view_sales");
                row["view_sales"] = decimal.Parse(sales.Substring(0, sales.Length - 3));
                row["nick"]       = obj.GetValue <string>("nick");
                table.Rows.Add(row);
            }
            dataGridView1.DataSource = table;
        }
Ejemplo n.º 5
0
        public object GetTaobaoRealPrice(string url, string refer, List <SkuMap> skuMaps)
        {
            string html = GetHtml(url, refer).ToString().Trim();
            string flag = "onSibRequestSuccess(";
            string data = html.Substring(flag.Length).TrimEnd(';').TrimEnd(')');

            if (!data.Contains("promoData"))
            {
                return(skuMaps);
            }
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();
            HashObject           hash       = serializer.Deserialize <HashObject>(data);

            string[] keys =
            {
                "data/deliveryFee/data/sendCity",
                "data/tradeContract/pay",
                "data/tradeContract/service",
                "data/couponActivity/coupon/couponList",
                "data/promotion/promoData",
                "data/dynStock/sku",
                "data/promotion/soldQuantity/soldTotalCount",
                "data/promotion/soldQuantity/confirmGoodsCount"
            };
            var temp = hash.GetHashValue(keys);

            Goods goods = new Goods();

            goods.SendCity          = temp.GetDataEx <string>("sendCity");
            goods.Pays              = GetGoodsPayWay(temp.GetDataEx <ArrayList>("pay"));
            goods.Service           = GetGoodsService(temp.GetDataEx <ArrayList>("service"));
            goods.Skus              = skuMaps;
            goods.Coupon            = GetGoodsCoupon(temp.GetDataEx <ArrayList>("couponList"));
            goods.SoldTotalCount    = temp.GetDataEx <decimal>("soldTotalCount");
            goods.ConfirmGoodsCount = temp.GetDataEx <decimal>("confirmGoodsCount");

            HashObject promoDatas = temp.GetDataEx <HashObject>("promoData");

            if (promoDatas != null)
            {
                foreach (SkuMap map in skuMaps)
                {
                    object keySku;
                    if (promoDatas.TryGetValue(map.Key, out keySku))
                    {
                        ArrayList list     = (ArrayList)keySku;
                        decimal   minPrice = map.PromotionPrice;
                        foreach (HashObject tempList in list)
                        {
                            minPrice = Math.Min(minPrice, tempList.GetValue <decimal>("price"));
                        }
                        map.PromotionPrice = minPrice;
                    }
                }
            }

            HashObject sku = temp.GetDataEx <HashObject>("sku");

            if (sku != null)
            {
                foreach (SkuMap map in skuMaps)
                {
                    object keySku;
                    if (sku.TryGetValue(map.Key, out keySku))
                    {
                        map.Stock = ((HashObject)keySku).GetValue <decimal>("sellableQuantity");
                    }
                }
            }
            return(goods);
        }
Ejemplo n.º 6
0
        public static DataTable SpliteContentToDataTable(string user, List <CatchDataTemplate> list)
        {
            DataTable            table      = MessageTable();
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();

            string[] keys =
            {
                "mainOrder/payInfo/actualFee/value",
                "mainOrder/buyer/nick",
                "mainOrder/id",
                "mainOrder/orderInfo/lines",
                "mainOrder/subOrders",
                "buyMessage",                    //买家备注
                "operationsGuide"                //卖家备注
            };
            foreach (CatchDataTemplate template in list)
            {
                var    hashObject = new HashObject();
                string content    = template.DetailContent;
                try
                {
                    hashObject = serializer.Deserialize <HashObject>(content);
                }
                catch (Exception t)
                {
                    continue;
                }

                DataRow    row = table.NewRow();
                HashObject addressAndLogistics = GeAddressAndLogisticsInfo(hashObject);
                foreach (string key in addressAndLogistics.Keys)
                {
                    row[key] = addressAndLogistics[key];
                }
                var newHash = hashObject.GetHashValue(keys);
                row["订单ID"] = newHash.GetDataEx <string>("id");
                row["旺旺名称"] = newHash.GetDataEx <string>("nick");
                row["买家留言"] = newHash.GetDataEx <string>("buyMessage");

                row["卖家留言"] = GetSaleMessage(GetKeyObject(newHash, "operationsGuide"));
                ArrayList       linesList     = newHash.GetDataEx <ArrayList>("lines");
                IHashObjectList orderInfoList = GetOrderInfoList(serializer, linesList);
                if (orderInfoList.Count > 1 || orderInfoList.Count == 0)
                {
                    throw new Exception("订单信息存在多个时间,请重新核实");
                }
                IHashObject tempOrderInfoList = orderInfoList[0];
                row["支付宝交易号"] = tempOrderInfoList.GetValue <string>("支付宝交易号:", "");
                row["创建时间"]   = tempOrderInfoList.GetValue <string>("创建时间:", null);
                row["付款时间"]   = tempOrderInfoList.GetValue <string>("付款时间:", null);
                var sendDate = tempOrderInfoList.GetValue <string>("发货时间:", null);
                row["发货时间"] = sendDate;
                if (sendDate != null)
                {
                    row["发货状态"]       = "已发货";
                    row["发货状态status"] = "1";
                }

                var successDate = tempOrderInfoList.GetValue <string>("成交时间:", null);
                if (successDate != null)
                {
                    row["发货状态"]       = "已收货";
                    row["发货状态status"] = "2";
                }
                row["成交时间"] = successDate;

                //后期单据退款(各种原因的退款)
                if ("交易关闭".Equals(template.Status))
                {
                    row["支付金额"]       = 0;
                    row["发货状态"]       = "已关闭";
                    row["发货状态status"] = "9";
                }
                else
                {
                    row["支付金额"] = newHash.GetDataEx <string>("value"); //支付总金额
                    newHash.GetDataEx <string>("value");               //支付总金额
                }

                ArrayList        subOrders = newHash.GetDataEx <ArrayList>("subOrders");
                List <GoodsInfo> gList     = GetSubOrderSkuList(subOrders);
                decimal          all       = 0;
                foreach (GoodsInfo info in gList)
                {
                    all += info.PriceInfo;
                }
                row["拍下总金额"] = all;
                row["货物信息"]  = serializer.Serialize(gList);
                row["所属用户"]  = user;
                table.Rows.Add(row);
            }

            return(table);
        }