Esempio n. 1
0
        public Page<OrderData> List(BaseParm parm)
        {
            var page = new Page<OrderData>(parm);
            var strSql = new StringBuilder();
            strSql.Append("select ID,OrderNo,State,UserID,UserName,PMoney,Money,Amount,CreateDate,Remark,Address,SendTime,Phone,SendType,SendMoney from  `order` where 1=1");
            strSql.Append(" And UserID=@Id");
            if (parm.Type != "全部")
            {
                strSql.Append(" AND State = @Type");
            }
            strSql.Append(" ORDER BY CreateDate DESC");
            var list = _db.SkipTake<OrderData>(parm.page * parm.rows, parm.rows, strSql.ToString(), parm);
            if (list.Any())
            {
                var details = _db.Query<OrderDetail>(@"select o.*,p1.Url from orderdetail o 
                                LEFT JOIN product p ON p.ID=o.ProductID
                              LEFT JOIN (SELECT * FROM productimg n WHERE n.RowNO=0) p1 ON p1.ProductID=p.ID
                                where o.orderno in (@0)", list.Select(n => n.OrderNo)).ToList();
                list.ForEach(n =>
                {
                    n.Detail = details.Where(m => m.OrderNo == n.OrderNo).ToList();
                });
            }

            page.rows = list;
            return page;
        }