/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <User> GetUserList(UserModel userModel, int pageIndex, int pageSize, string keyword) { var roles = Da.GetListAsync <UserRole>(); var list = GetUserList(userModel); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.UserEmail} {p.UserNickName} {p.UserChnName} {p.Remark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <User>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; if (result.data.Count > 0) { Task.WaitAll(roles); foreach (var item in result.data) { item.UserRoleName = roles.Result.Find(p => p.UserRoleId == item.UserRoleId)?.UserRoleName; } } return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="categoryId"></param> /// <param name="keyword"></param> /// <param name="orderBy"></param> /// <returns></returns> public virtual PagenationResult <Product> GetProductListResult(UserModel userModel, int pageIndex, int pageSize, int?categoryId, string keyword, Func <List <Product>, List <Product> > orderBy) { var currencys = Da.GetListAsync <Currency>(); var cate = Da.GetListAsync <Category>(); var list = GetProductList(userModel); //排序 list = orderBy.Invoke(list); if (categoryId.HasValue && categoryId.Value > 0) { Task.WaitAll(cate); var childs = cate.Result.GetChildNodes(categoryId.Value, p => p.CategoryId, p => p.CategoryParentId, true) ?? new List <Category>(); var categoryIds = childs.Select(p => p.CategoryId).ToList(); if (string.IsNullOrWhiteSpace(keyword)) { list = list.Where(p => categoryIds.Contains(p.CategoryId)).ToList(); } else { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.ProductSku} {p.ProductName} {p.ProductSpecification} {p.ProductRemark} {p.CreateName} {p.AreaPosition}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false) && categoryIds.Contains(p.CategoryId)).ToList(); } } else { if (!string.IsNullOrWhiteSpace(keyword)) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.ProductSku} {p.ProductName} {p.ProductSpecification} {p.ProductRemark} {p.CreateName} {p.AreaPosition}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } Task.WaitAll(cate); } if (list.Count > 0) { list.ForEach(item => { var parentCates = cate.Result.GetParentNodes(item.CategoryId, p => p.CategoryId, p => p.CategoryParentId, true); if (parentCates != null) { item.CategoryName = string.Join("|", parentCates.Select(p => p.CategoryName)); } }); } Task.WaitAll(currencys); var result = new PagenationResult <Product>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(), obj = currencys.Result, }; return(result); }
public PagenationResult <User> GetUserList(string userEmail, Guid?userRoleId, int pageIndex, int pageSize) { var lists = Da.GetUserList().Where(p => (string.IsNullOrWhiteSpace(userEmail) || p.UserEmail.IsContains(userEmail)) && (!userRoleId.HasValue || userRoleId.Value == Guid.Empty || p.UserRoleId == userRoleId)).ToList(); var result = new PagenationResult <User>() { count = lists.Count, data = lists.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
public PagenationResult <UserRole> GetUserRoleList(string roleName, int pageIndex, int pageSize) { var lists = Da.GetList <UserRole>().Where(p => string.IsNullOrWhiteSpace(roleName) || p.UserRoleName.IsContains(roleName)).ToList(); var result = new PagenationResult <UserRole>() { count = lists.Count, data = lists.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <FriendLink> GetFriendLinkList(int pageIndex, int pageSize, string keyword) { var list = GetFriendLinkList().Where(p => p.FriendLinkName.IsContains(keyword)).ToList(); var result = new PagenationResult <FriendLink>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
/// <summary> /// 没有搜索 /// </summary> /// <param name="userModel"></param> /// <param name="list"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> private PagenationResult <StockInResult> GetStockInList(UserModel userModel, List <StockIn> list, int pageIndex, int pageSize) { var result = new PagenationResult <StockInResult>() { count = list.Count, PageIndex = pageIndex, PageSize = pageSize, }; var rows = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); var productIds = rows.Select(p => p.ProductId).Distinct().ToList(); var products = Da.GetListByBulk <Product>(new { ProductId = productIds, }).ToList(); var items = new List <StockInResult>(); foreach (var item in rows) { var m = new StockInResult() { Number = item.BuyOrderNumber, UserName = item.UserNickName, Price = item.Price, Qty = item.InQty, Remark = item.Remark, InStockRemark = item.InStockRemark, CreateDate = item.CreateDate, }; var obj = products.Find(p => p.ProductId == item.ProductId); if (obj != null) { m.ProductId = obj.ProductId; m.Sku = obj.ProductSku; m.Name = obj.ProductName; m.Specification = obj.ProductSpecification; m.Description = obj.ProductRemark; m.ImageQty = obj.ImageQty; } items.Add(m); } result.data = items; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="saleOrderId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <SaleReceive> GetSaleReceiveList(UserModel userModel, Guid saleOrderId, int pageIndex, int pageSize, string keyword) { var list = GetSaleReceiveList(userModel, saleOrderId); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.AccountInfo} {p.CurrencySymbol} {p.Remark} {p.CreateName}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <SaleReceive>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <SaleOrderProduct> GetSaleOrderProductList(UserModel userModel, int pageIndex, int pageSize, string keyword) { var list = GetSaleOrderProductList(userModel); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.Remark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <SaleOrderProduct>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <SaleOrder> GetSaleOrderList(UserModel userModel, int pageIndex, int pageSize, string keyword) { var list = GetSaleOrderList(userModel); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.SaleOrderNumber} {p.CurrencyName} {p.CurrencyText} {p.CurrencySymbol} {p.Title} {p.ToConsignee} {p.ToCompanyName} {p.ToTelphone} {p.ToAddress} {p.ToRemark} {p.StockStartName} {p.StockEndName} {p.StockRemark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <SaleOrder>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <BuySupplier> GetBuySupplierList(UserModel userModel, int pageIndex, int pageSize, string keyword) { var list = GetBuySupplierList(userModel); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.SupplierCompany} {p.SupplierName} {p.SupplierTel} {p.SupplierMobilePhone} {p.SupplierEmail} {p.SupplierQQ} {p.SupplierWechat} {p.SupplierAddress} {p.SupplierRemark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <BuySupplier>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <UserRole> GetUserRoleList(UserModel userModel, int pageIndex, int pageSize, string keyword) { var users = Da.GetListAsync <User>(); var list = GetUserRoleList(userModel); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.UserRoleName}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <UserRole>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() }; if (result.data.Count > 0) { Task.WaitAll(users); var userLists = users.Result.OrderBy(p => p.Status).ThenByDescending(p => p.IsAdmin).ToList(); foreach (var item in result.data) { var us = userLists.Where(p => p.UserRoleId == item.UserRoleId).Select(p => { string str; if (p.Status == (int)UserStatusEnum.Disabled) { str = $"<span class=\"disText\">{p.UserNickName}</span>"; } else if (p.Status == (int)UserStatusEnum.Delete) { str = $"<span class=\"delText\">{p.UserNickName}</span>"; } else { str = p.UserNickName; } return(str); }).ToList(); item.UserNames = string.Join("、", us); } } return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <returns></returns> public virtual PagenationResult <StockInResult> GetStockInList(UserModel userModel, int pageIndex, int pageSize, string keyword) { var list = Da.GetList <StockIn>().OrderByDescending(p => p.StockInId).ToList(); //没有搜索关键词 if (keyword.IsWhiteSpace()) { return(GetStockInList(userModel, list, pageIndex, pageSize)); } //搜索关键词 var products = Da.GetList <Product>(); var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); var rows = list.Join(products, p => p.ProductId, p => p.ProductId, (p, q) => new { p, q }) .Select(m => new StockInResult() { ProductId = m.p.ProductId, Number = m.p.BuyOrderNumber, UserName = m.p.UserNickName, Sku = m.q.ProductSku, Name = m.q.ProductName, Specification = m.q.ProductSpecification, Description = m.q.ProductRemark, ImageQty = m.q.ImageQty, Price = m.p.Price, Qty = m.p.InQty, Remark = m.p.Remark, InStockRemark = m.p.InStockRemark, CreateDate = m.p.CreateDate, }).Where(p => $"{p.Number} {p.Sku} {p.UserName} {p.Name} {p.Specification} {p.Description} {p.Remark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); var result = new PagenationResult <StockInResult>() { count = list.Count, PageIndex = pageIndex, PageSize = pageSize, data = rows }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <param name="status"></param> /// <param name="orderBy"></param> /// <returns></returns> private static PagenationResult <SaleOrderListResult> GetListByStatus(UserModel userModel, int pageIndex, int pageSize, string keyword, List <int> status, Func <List <SaleOrder>, List <SaleOrder> > orderBy) { var list = Da.GetListByBulk <SaleOrder>(new { Status = status }); //排序 list = orderBy.Invoke(list); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.SaleOrderNumber} {p.CurrencyName} {p.CurrencyText} {p.CurrencySymbol} {p.Title} {p.ToConsignee} {p.ToCompanyName} {p.ToTelphone} {p.ToAddress} {p.ToRemark} {p.StockStartName} {p.StockEndName} {p.StockRemark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <SaleOrderListResult>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToSaleOrderListResult() }; return(result); }
/// <summary> /// 获取列表 /// </summary> /// <param name="userModel"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="keyword"></param> /// <param name="status"></param> /// <param name="orderBy"></param> /// <returns></returns> private static PagenationResult <BuyOrderListResult> GetListByStatus(UserModel userModel, int pageIndex, int pageSize, string keyword, List <int> status, Func <List <BuyOrder>, List <BuyOrder> > orderBy) { var list = Da.GetListByBulk <BuyOrder>(new { Status = status }); //排序 list = orderBy.Invoke(list); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); list = list.Where(p => $"{p.BuyOrderNumber} {p.Title} {p.DefaultShip} {p.DefaultAccount} {p.DefaultRemark} {p.SupplierCompany} {p.SupplierName} {p.SupplierTel} {p.SupplierMobilePhone} {p.SupplierEmail} {p.SupplierQQ} {p.SupplierWechat} {p.SupplierAddress} {p.StockInRemark}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <BuyOrderListResult>() { count = list.Count, data = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToBuyOrderListResult() }; return(result); }
/// <summary> /// 产品统计 (带搜索条件) /// </summary> /// <param name="userModel"></param> /// <param name="beginDate"></param> /// <param name="endDate"></param> /// <param name="userId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="categoryId"></param> /// <param name="keyword"></param> public PagenationResult <StockCountResult> GetSaleProductStatisticsKey(UserModel userModel, DateTime beginDate, DateTime endDate, Guid?userId, int pageIndex, int pageSize, int?categoryId, string keyword) { var param = new { }; var paramUser = userId.HasValue ? (object)new { UserId = userId.Value, } : param; var categoryAsync = Da.GetListAsync <Category>(param); var productAsync = Da.GetListAsync <Product>(param); var outAsync = Task.Run(() => { var end = endDate.Date.AddDays(1); var list = Da.GetList <StockOut>(paramUser).Where(p => p.CreateDate >= beginDate && p.CreateDate < end).GroupBy(p => new { p.ProductId }, (p, q) => { var rs = q.ToList(); var m = new StockCountResult { ProductId = p.ProductId, Qty = rs.Sum(g => g.Qty), Amount = rs.Sum(g => g.Qty * g.Price), }; m.Avg = Math.Round(m.Amount / m.Qty, 2); return(m); }).OrderByDescending(p => p.Qty).ToList(); return(list); }); Task.WaitAll(categoryAsync, productAsync, outAsync); var categorys = categoryAsync.Result; var products = productAsync.Result; var items = outAsync.Result; if (categoryId.HasValue && categoryId.Value > 0) { var cids = categorys.GetChildNodes(categoryId.Value, p => p.CategoryId, p => p.CategoryParentId, true); //排除产品 products = products.Join(cids, p => p.CategoryId, p => p.CategoryId, (p, q) => p).ToList(); } var rows = items.Join(products, p => p.ProductId, p => p.ProductId, (p, q) => { var m = MapperHelper.Mapper <Product, StockCountResult>(q); m.Qty = p.Qty; m.Amount = p.Amount; m.Avg = p.Avg; var cates = categorys.GetParentNodes(m.CategoryId, g => g.CategoryId, g => g.CategoryParentId, true); m.CategoryName = string.Join(">", cates.Select(g => g.CategoryName)); return(m); }) // ReSharper disable once ReturnValueOfPureMethodIsNotUsed .ToList(); if (!keyword.IsWhiteSpace()) { var keys = keyword.ToKeys(StringComparer.OrdinalIgnoreCase).ToList(); rows = rows.Where(p => $"{p.ProductSku} {p.ProductName} {p.ProductSpecification} {p.ProductRemark} {p.CreateName} {p.AreaPosition}".HasSearchKeys(keys, StringComparison.OrdinalIgnoreCase, false)).ToList(); } var result = new PagenationResult <StockCountResult>() { count = rows.Count, data = rows.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(), PageIndex = pageIndex, PageSize = pageSize, }; return(result); }