コード例 #1
0
ファイル: PlugList.cs プロジェクト: ljbbean/project
            protected override DataTable DoQuery(DbHelper db)
            {
                JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();
                string    sql   = "select * from plugs";
                DataTable table = db.ExecuteSQL(sql);

                table.Columns.Add("info");
                table.Columns.Add("ppic1");
                table.Columns.Add("ppic2");
                table.Columns.Add("ppic3");
                foreach (DataRow row in table.Rows)
                {
                    IHashObjectList list = new HashObjectList();
                    IHashObject     nr   = new HashObject();
                    nr["001"] = string.Format("<a href='{0}' target='_blank'>下载地址</a>&nbsp;&nbsp;", row["pdownpath"]);
                    list.Add(nr);
                    nr        = new HashObject();
                    nr["002"] = string.Format("<a href='{0}' target='_blank'>视频地址</a>", row["pvideo"]);
                    list.Add(nr);
                    row["info"] = serializer.Serialize(list);

                    string   ppics    = row["ppics"].ToString();
                    string[] picArray = ppics.Split(',');
                    row["ppic1"] = picArray[0];
                    row["ppic2"] = picArray[1];
                    row["ppic3"] = picArray[2];
                }
                return(table);
            }
コード例 #2
0
ファイル: TaobaoDataHelper.cs プロジェクト: ljbbean/project
        private static List <GoodsInfo> GetSubOrderSkuList(ArrayList subOrders)
        {
            List <GoodsInfo> gList = new List <GoodsInfo>();

            string[] subOrderKeys = { "itemInfo/skuText", "itemInfo/title", "quantity", "priceInfo" };
            foreach (HashObject subOrder in subOrders)
            {
                GoodsInfo       info            = new GoodsInfo();
                IHashObjectList subOrderSkuList = new HashObjectList();
                var             subList         = subOrder.GetHashValue(subOrderKeys);
                ArrayList       skuText         = subList.GetDataEx <ArrayList>("skuText");
                HashObject      thash           = new HashObject();
                info.Amount = ((HashObject)subList[2]).GetValue <string>("quantity");
                subOrderSkuList.Add(thash);
                foreach (HashObject skuTextItem in skuText)
                {
                    ArrayList skuTextItemContent = skuTextItem.GetValue <ArrayList>("content");

                    IHashObject data = new HashObject();
                    foreach (HashObject skuTextItemContentDetial in skuTextItemContent)
                    {
                        if (!"namevalue".Equals(skuTextItemContentDetial.GetValue <string>("type")))
                        {
                            continue;
                        }
                        HashObject tHash = skuTextItemContentDetial.GetValue <HashObject>("value");
                        if ("颜色分类:".Equals(tHash.GetValue <string>("name")))
                        {
                            info.Color = tHash.GetValue <string>("value");
                        }
                        if ("尺寸:".Equals(tHash.GetValue <string>("name")))
                        {
                            info.Size = tHash.GetValue <string>("value");
                        }
                    }
                    if (data.Keys.Count == 0)
                    {
                        continue;
                    }
                    subOrderSkuList.Add(data);
                }
                if (subOrderSkuList.Count == 0)
                {
                    continue;
                }
                info.PriceInfo = decimal.Parse(subList.GetDataEx <string>("priceInfo"));
                info.Title     = subList.GetDataEx <string>("title");
                gList.Add(info);
            }
            return(gList);
        }
コード例 #3
0
ファイル: TaobaoDataHelper.cs プロジェクト: ljbbean/project
        private static IHashObjectList GetOrderInfoList(JavaScriptSerializer serializer, ArrayList linesList)
        {
            IHashObjectList orderInfoList = new HashObjectList();

            foreach (HashObject thash in linesList)
            {
                var content = thash.GetValue <ArrayList>("content");
                if (content.Count == 0)
                {
                    continue;
                }

                IHashObject orderInfo = new HashObject();
                foreach (HashObject contentItem in content)
                {
                    var    contentItemValue = contentItem.GetValue <HashObject>("value");
                    string key = contentItemValue.GetValue <string>("name");
                    if (!contentItemValue.ContainsKey("value"))
                    {
                        continue;
                    }
                    if (contentItemValue["value"] is ArrayList)
                    {
                        orderInfo[key] = serializer.Serialize(contentItemValue["value"]);
                        continue;
                    }
                    orderInfo[key] = contentItemValue["value"].ToString();
                }
                orderInfoList.Add(orderInfo);
            }
            return(orderInfoList);
        }
コード例 #4
0
        private object GetLineData(Dictionary <string, Dictionary <string, decimal> > data, List <string> xAxisData)
        {
            HashObject list  = new HashObject();
            HashObject title = new HashObject();

            title.Add("text", "商品销量数量");
            list.Add("title", title);
            HashObject legend = new HashObject();

            legend.Add("data", data.Keys);
            list.Add("legend", legend);
            HashObject xAxis = new HashObject();

            xAxis.Add("data", xAxisData);
            list.Add("xAxis", xAxis);
            HashObject yAxis = new HashObject();

            yAxis.Add("type", "value");
            list.Add("yAxis", yAxis);

            HashObjectList series = new HashObjectList();

            list.Add("series", series);

            foreach (string key in data.Keys)
            {
                Dictionary <string, decimal> chatlist = data[key];

                List <decimal> seriesData = new List <decimal>();
                foreach (string item in xAxisData)
                {
                    if (chatlist.ContainsKey(item))
                    {
                        seriesData.Add(chatlist[item]);
                    }
                    else
                    {
                        seriesData.Add(0);
                    }
                }
                HashObject seriesItem = new HashObject();
                seriesItem.Add("name", key);
                seriesItem.Add("type", "line");
                seriesItem.Add("data", seriesData);
                HashObject normal    = new HashObject();
                HashObject label     = new HashObject();
                HashObject itemStyle = new HashObject();
                label.Add("show", true);
                normal.Add("label", label);
                itemStyle.Add("normal", normal);
                seriesItem.Add("itemStyle", itemStyle);
                series.Add(seriesItem);
            }

            return(list);
        }
コード例 #5
0
ファイル: DataHelper.cs プロジェクト: ljbbean/project
        public static IHashMapList DataTableToObjectList(DataTable table, int first, int count)
        {
            int            rowCount = Math.Min(count, table.Rows.Count - first);
            HashObjectList records  = new HashObjectList(rowCount);

            for (int i = 0; i < rowCount; i++)
            {
                records.Add(DataRowToObject(table, table.Rows[first + i]));
            }
            return(records);
        }
コード例 #6
0
        public virtual async Task <IHashObjectList> ListAsync(string sql, IHashObject parms)
        {
            IHashObjectList list = new HashObjectList();
            var             cmd  = GetCommand(sql, false, parms);

            using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow))
            {
                while (await reader.ReadAsync())
                {
                    list.Add(ReaderTohashObj(reader));
                }
            }
            return(list);
        }
コード例 #7
0
        private IHashObjectList GetDataList(HashObject data)
        {
            IHashObjectList list = new HashObjectList();

            foreach (HashObject item in data.GetValue <ArrayList>("data"))
            {
                HashObject copy = new HashObject();
                copy.Add("gid", item["goodid"]);
                copy.Add("title", item["title"]);
                copy.Add("url", item["url"]);
                copy.Add("startDate", Utils.ConvertUnixDate(item.GetValue <long>("start")));
                copy.Add("endDate", Utils.ConvertUnixDate(item.GetValue <long>("end")));
                long temp = item.GetValue <long>("create");
                copy.Add("create", temp == 0 ? "" : Utils.ConvertUnixDate(temp));
                list.Add(copy);
            }
            return(list);
        }
コード例 #8
0
ファイル: DataCatchSave.cs プロジェクト: ljbbean/project
        private static void BuildBillDataFromTable(string suser, bool onlyAdd, DataTable table, HashObjectList billList, HashObjectList detailList, DbHelper db = null, string ids = null, bool sureRate = true)
        {
            Dictionary <string, string> dic = GetExistBills(db, ids);
            List <string>        dicDetail  = GetExistBillDetails(db, ids);
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();

            foreach (DataRow row in table.Rows)
            {
                var    ddid = row["订单ID"].ToString();
                string id   = Cuid.NewCuid().GetHashCode().ToString();
                string oldid;
                if (dic.TryGetValue(ddid, out oldid))
                {
                    if (onlyAdd)
                    {
                        continue;
                    }
                    id = oldid;
                }
                string user = row["所属用户"].ToString();
                if (user != suser)
                {
                    throw new Exception("分析用户和数据保存用户不匹配,无法做数据保存");
                }
                object sendDate    = row["发货时间"];
                object successDate = row["成交时间"];

                Dictionary <string, decimal> goodsRate = GetGoodsRate(db, user);
                GoodsInfo[] ginfos = serializer.Deserialize <GoodsInfo[]>(row["货物信息"].ToString());

                var     sendWay  = TaobaoDataHelper.GetLogisticsInfo(row["快递公司"]).IsEmptyObject() ? null : "快递";
                string  remark   = GetRemark(row);
                decimal pall     = Decimal.Parse(row["拍下总金额"].ToString());
                decimal total    = Decimal.Parse(row["支付金额"].ToString());
                decimal ltotal   = 0;
                decimal btotal   = 0;
                decimal allPrice = 0;

                string address = TaobaoDataHelper.ReplaceHtmlText(row["具体地址"].ToString());
                if (!dicDetail.Contains(ddid))
                {
                    for (int j = ginfos.Length - 1; j >= 0; j--)
                    {
                        GoodsInfo ginfo   = ginfos[j];
                        string    goodKey = GetGoodsKey(ginfo.Color, ginfo.Size, ginfo.Title);
                        decimal   rate    = 0;
                        if (db != null && (goodsRate == null || !goodsRate.ContainsKey(goodKey)))
                        {
                            if (!sureRate)
                            {
                                rate = 0;
                            }
                            else
                            {
                                throw new Exception(string.Format("【{3}】   color:{0} size:{1} title:{2}没有设置比例goodMatchRate", ginfo.Color, ginfo.Size, ginfo.Title, user));
                            }
                        }
                        else
                        {
                            if (db != null)
                            {
                                rate = goodsRate[goodKey];
                            }
                        }
                        decimal price = ginfo.PriceInfo / pall * total;
                        if (j == 0)
                        {
                            price = total - allPrice;
                        }
                        allPrice += price;
                        decimal tbtotal = (price * rate) * (decimal)(0.01);
                        btotal += tbtotal;
                        decimal    tltotal    = price - tbtotal;
                        HashObject detailHash = new HashObject();
                        detailList.Add(detailHash);
                        detailHash.Add("id", Cuid.NewCuid().GetHashCode());
                        detailHash.Add("bid", id);
                        detailHash.Add("code", ddid);
                        detailHash.Add("size", ginfo.Size);
                        detailHash.Add("amount", ginfo.Amount);
                        detailHash.Add("color", ginfo.Color);
                        detailHash.Add("address", address);
                        detailHash.Add("area", row["区域"]);
                        detailHash.Add("total", price);
                        detailHash.Add("remark", remark);
                        detailHash.Add("ltotal", tltotal);
                        detailHash.Add("sourceTitle", ginfo.Title);
                        detailHash.Add("goodsstatus", int.Parse(row["发货状态status"].ToString()) >= 1 ? 2 : 1);
                        detailHash.Add("sendway", sendWay);
                        detailHash.Add("btotal", tbtotal);
                    }
                    ltotal = total - btotal;
                }

                if (IsNullDate(row["付款时间"]))
                {
                    continue;
                }

                HashObject billHash = new HashObject();
                billHash.Add("id", id);
                billHash.Add("date", row["付款时间"]);
                billHash.Add("taobaocode", row["旺旺名称"]);
                billHash.Add("cname", row["收货客户"]);
                billHash.Add("ctel", row["联系电话"]);
                billHash.Add("caddress", address);
                billHash.Add("carea", row["区域"]);
                billHash.Add("cremark", remark);
                billHash.Add("ltotal", ltotal);
                billHash.Add("status", row["发货状态status"]);
                billHash.Add("scode", TaobaoDataHelper.GetLogisticsInfo(row["物流单号"]));
                billHash.Add("sname", TaobaoDataHelper.GetLogisticsInfo(row["快递公司"]));
                billHash.Add("uid", GetUser(row["所属用户"], db == null));
                billHash.Add("goodsstatus", 1);
                billHash.Add("billfrom", "抓取");
                billHash.Add("createdate", row["创建时间"]);
                billHash.Add("zfbpaycode", row["支付宝交易号"]);
                billHash.Add("tbcode", ddid);
                billHash.Add("total", total);
                billHash.Add("btotal", btotal);
                billHash.Add("senddate", GetDate(sendDate));
                billHash.Add("successdate", GetDate(successDate));
                billList.Add(billHash);
            }
        }