Beispiel #1
0
        public ApiPagedResult <List <TopTrade> > GetSoldTrade(string status, int page, DateTime start)
        {
            ITopClient           client  = GetTopClient();
            TradesSoldGetRequest request = new TradesSoldGetRequest
            {
                Fields = "tid,buyer_nick,num,num_iid,created,pay_time,payment,receiver_address,status,end_time,seller_rate,seller_can_rate"
            };

            request.StartCreated = start;
            request.EndCreated   = DateTime.Now;
            request.Status       = status;
            request.Type         = "guarantee_trade";
            request.PageNo       = page;
            request.PageSize     = 50;
            request.UseHasNext   = true;

            TradesSoldGetResponse response = client.Execute <TradesSoldGetResponse>(request, AccessToken);
            List <TopTrade>       list     = new List <TopTrade>();

            if (!response.IsError)
            {
                list = response.Trades.Select(x => TopTrade.FromTrade(x)).ToList();
            }
            return(response.AsApiPagedResult(list, response.HasNext));
        }
Beispiel #2
0
        /// <summary>
        /// 获取交易信息
        /// </summary>
        /// <param name="tid"></param>
        /// <returns></returns>
        public ApiResult <TopTrade> GetTrade(long tid)
        {
            ITopClient client = GetTopClient();
            TradeFullinfoGetRequest request = new TradeFullinfoGetRequest
            {
                Tid    = tid,
                Fields = "tid,buyer_nick,num,num_iid,created,pay_time,payment,receiver_address,status,end_time,seller_rate,seller_can_rate"
            };
            var rsp = client.Execute(request, AccessToken);

            return(rsp.AsApiResult <TopTrade>(() => TopTrade.FromTrade(rsp.Trade)));
        }
Beispiel #3
0
            /// <summary>
            /// 同步已卖出的交易数据
            /// </summary>
            /// <param name="orders"></param>
            /// <param name="orderOpr"></param>
            /// <param name="status"></param>
            /// <param name="pageno"></param>
            /// <param name="daysago"></param>
            /// <returns></returns>
            public ApiPagedResult <List <TopTrade> > SyncTrade(string status, long pageno, DateTime start, Models.UserTaoOAuth taoUserOAuth)
            {
                var                  orderList = new List <TbOrder>();
                ITopClient           client    = new DefaultTopClient(url_api, this.AppKey, this.AppSecret);
                TradesSoldGetRequest request   = new TradesSoldGetRequest
                {
                    Fields = "tid,buyer_nick,num_iid,created,pay_time,payment,receiver_address,status,end_time,seller_rate,seller_can_rate"
                };

                request.StartCreated = start;
                request.EndCreated   = DateTime.Now;
                request.Status       = status;
                request.Type         = "guarantee_trade";
                request.PageNo       = pageno;
                request.PageSize     = 50;
                request.UseHasNext   = true;

                TradesSoldGetResponse response = client.Execute <TradesSoldGetResponse>(request, taoUserOAuth.access_token);
                var result = new ApiPagedResult <List <TopTrade> >(!response.IsError, response.ErrMsg + " " + response.SubErrMsg);

                if (!response.IsError)
                {
                    result.Data    = response.Trades.Select(x => TopTrade.FromTrade(x)).ToList();
                    result.HasMore = response.HasNext;
                }
                return(result);
                //XmlDocument doc = new XmlDocument();
                //response.Trades.First().ser
                //doc.LoadXml(response.Body);
                ////string json = JsonConvert.SerializeXmlNode(doc);
                //XmlNodeList xnltrades = doc.SelectNodes("//trade");
                //if (xnltrades != null && xnltrades.Count > 0)
                //{
                //    foreach (XmlNode xntrade in xnltrades)
                //    {
                //        string jsontrade = JsonConvert.SerializeXmlNode(xntrade);
                //        var definition = new { trade = new { buyer_nick = "", created = new DateTime(), num_iid = "", tid = 0L, pay_time = (DateTime?)null, payment = 0.00, receiver_address = "", status = "" } };
                //        //{"trade":{"buyer_nick":"恋上你回眸","created":"2014-09-18 01:46:15","num_iid":"35071709812","tid":"807930976731116"}}
                //        var trade = JsonConvert.DeserializeAnonymousType(jsontrade, definition);

                //        TbOrder order = new TbOrder()
                //        {
                //            Tid = trade.trade.tid,
                //            Name = trade.trade.buyer_nick,
                //            BuyTime = trade.trade.created,
                //            Itemid = trade.trade.num_iid,
                //            Payment = trade.trade.payment,
                //            PayTime = trade.trade.pay_time,
                //            Status = trade.trade.status,
                //            ReceiverAddress = trade.trade.receiver_address,
                //            trade.seller_rate
                //        };
                //        orderList.Add(order);
                //    }
                //}
                //return new ApiPagedResult<List<TbOrder>>(true, "")
                //{
                //    HasMore = response.HasNext,
                //    Data = orderList
                //};
            }