Ejemplo n.º 1
0
        public ActionResult GetList(OrderDetailCauseSearch req)
        {
            if (req.ListType == 1)
            {
                req.offset = (req.offset - 1) * req.limit;
            }
            var list = _orderDetailCauseRepository.GetList(out int total, req);

            return(NewtonSoftJson(new { rows = list, total = total, code = 0, msg = "" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public List <OrderDetailCauseListDTO> GetList(out int total, OrderDetailCauseSearch req)
        {
            var companyId = OperatorProvider.Provider.GetCurrent().CompanyId.ToInt();

            using (var db = new SqlSugarClient(Connection))
            {
                int    totalCount = 0;
                string order      = string.Empty;
                List <OrderDetailCauseListDTO> list = new List <OrderDetailCauseListDTO>();

                if (!string.IsNullOrEmpty(req.Sort))
                {
                    if (req.Sort.Equals("id", StringComparison.OrdinalIgnoreCase))
                    {
                        order = "Id desc";
                    }
                    else
                    {
                        order = string.Format("{0} {1}", req.Sort, req.Order);
                    }
                }
                var data = db.Sqlable()
                           .From <R_OrderDetailCause>("")
                           .Where("IsDelete = 0  ");
                if (req.CauseType > 0)
                {
                    data = data.Where("CauseType=" + req.CauseType);
                }
                totalCount = data.Count();
                list       = data.SelectToPageList <OrderDetailCauseListDTO>(
                    @"*,(CASE CauseType WHEN 1 THEN '赠送' WHEN 2 THEN '退菜' end) AS CauseTypeName",
                    order, (req.offset / req.limit) + 1, req.limit, null);
                total = totalCount;
                return(list);
            }
        }