Пример #1
0
        /// <summary>
        /// 删除超过30天的订单
        /// </summary>
        private static void DeleteExpireOrder()
        {
            var paging = new PagingQuery {
                PageIndex = 1, PageSize = 50
            };

            using (var scope = App.DataBase.BeginLifetimeScope())
            {
                var service   = scope.Resolve <IOrderService>();
                var count     = service.Length <TangOrder>();
                var pageCount = Math.Ceiling(Convert.ToDouble(count) / Convert.ToDouble(paging.PageSize));
                var now       = DateTime.Now;
                for (int i = 0; i < pageCount; i++)
                {
                    paging.PageIndex += i;
                    var orders = service.GetRange <TangOrder>(paging, EntityStatus.All);
                    if (orders == null)
                    {
                        break;
                    }
                    orders.ForEach(order =>
                    {
                        if (order.CreateTime.Value.AddDays(30) > now)
                        {
                            return;
                        }
                        service.DeleteOrder(order);
                    });
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 获取商户订单列表
        /// </summary>
        /// <param name="business">商户对象</param>
        /// <param name="paging">分页参数</param>
        /// <returns></returns>
        public async static Task <List <Order> > GetOrdersAsync(Business business, PagingQuery paging)
        {
            var url    = $"{ApiUrl}/Client/GetOrders/{business.Id}?PageIndex={paging.PageIndex}&PageSize={paging.PageSize}&CreateTime={DateTime.Now:yyyy-MM-dd}";
            var result = await HttpRequestAsync(url);

            var jObj = JObject.Parse(result);
            var list = JsonConvert.DeserializeObject <List <Order> >(jObj["data"]["list"].ToString());

            paging.RecordCount = int.Parse(jObj["data"]["rows"].ToString());
            return(list);
        }