Ejemplo n.º 1
0
        public async Task <CashOrderSearchResult> GetModelListAsync(string keyword, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                CashOrderSearchResult result = new CashOrderSearchResult();
                var logs = dbc.GetAll <CashOrderEntity>().AsNoTracking();
                if (!string.IsNullOrEmpty(keyword))
                {
                    logs = logs.Where(a => a.OrderCode.Contains(keyword) ||
                                      a.BuyOrder.Buyer.Mobile.Contains(keyword) ||
                                      a.SellOrder.Seller.Mobile.Contains(keyword));
                }

                if (startTime != null)
                {
                    logs = logs.Where(a => a.CreateTime >= startTime);
                }
                if (endTime != null)
                {
                    logs = logs.Where(a => SqlFunctions.DateDiff("day", endTime, a.CreateTime) <= 0);
                }
                result.TotalCount = await logs.LongCountAsync();

                result.PageCount = (int)Math.Ceiling((result.TotalCount) * 1.0f / pageSize);
                var logsResult = await logs.OrderByDescending(a => a.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();

                result.log = logsResult.Select(a => ToDTO(a)).ToArray();
                return(result);
            }
        }
Ejemplo n.º 2
0
        //平台收支记录
        public async Task <CashOrderSearchResult> GetPaymentsListAsync(long?orderId, int pageIndex, int pageSize)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                CashOrderSearchResult result = new CashOrderSearchResult();
                var logs = dbc.GetAll <CashOrderEntity>().AsNoTracking();


                if (orderId != null && orderId > 0)
                {
                    logs = logs.Where(a => a.Id == orderId);
                }
                result.PageCount = (int)Math.Ceiling((await logs.LongCountAsync()) * 1.0f / pageSize);
                var logsResult = await logs.OrderByDescending(a => a.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();

                result.log = logsResult.Select(a => ToDTO(a)).ToArray();
                return(result);
            }
        }