コード例 #1
0
        public ContentResult orderlist(OrderListQueryRequest request)
        {
            var data = _orderService.List(request);
            var res  = new ResultDto <OrderListResponse>
            {
                page    = request.PageIndex,
                total   = request.Total,
                records = request.Records,
                rows    = data
            };

            return(Content(res.Serialize()));
        }
コード例 #2
0
        //订单列表
        public List <OrderListResponse> List(OrderListQueryRequest request)
        {
            List <OrderListResponse> list = new List <OrderListResponse>();

            try
            {
                StringBuilder join = new StringBuilder();
                if (request.KeyValue.IsNotEmpty())
                {
                    request.KeyValue = $"%{request.KeyValue}%";
                    join.Append(" and (b.code like @KeyValue or b.account like @KeyValue) ");
                }
                if (request.OrderType.HasValue && request.OrderType > 0)
                {
                    join.Append(" and a.orderType=@OrderType ");
                }
                if (request.OrderStatus.HasValue && request.OrderStatus > 0)
                {
                    join.Append(" and a.orderStatus=@OrderStatus ");
                }
                if (request.StartDate.HasValue)
                {
                    join.Append(" and a.createtime >= @StartDate");
                }
                if (request.EndDate.HasValue)
                {
                    request.EndDate = request.EndDate.Value.AddDays(1).AddSeconds(-1);
                    join.Append("  and a.createtime<=@EndDate");
                }
                var sql        = $@"select a.*,b.code MemberCode,b.account MemberAccount from t_order a
                             inner join t_member b on a.memberId=b.id
                             where a.isdelete=0 {join.ToString()} order by a.createtime desc";
                int totalCount = 0;
                list            = _dbContext.Page <OrderListResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request);
                request.Records = totalCount;
            }
            catch (Exception ex)
            {
                LogUtils.LogError("OrderService.List", ex);
            }
            return(list);
        }