diff --git a/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs b/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs index 88a3afdf..d0741c88 100644 --- a/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs +++ b/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs @@ -22,6 +22,15 @@ namespace CoreCms.Net.IRepository /// public interface ICoreCmsGoodsBrowsingRepository : IBaseRepository { + + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + + Task GetUserCountAsync(int userId); + /// /// 重写根据条件查询分页数据 /// diff --git a/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs b/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs index 1e36b76c..b700cc97 100644 --- a/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs +++ b/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs @@ -22,6 +22,15 @@ namespace CoreCms.Net.IServices /// public interface ICoreCmsGoodsBrowsingServices : IBaseServices { + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + + Task GetUserCountAsync(int userId); + + /// /// 重写根据条件查询分页数据 /// diff --git a/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs b/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs index d43ff397..455ce44a 100644 --- a/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs +++ b/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs @@ -28,6 +28,21 @@ namespace CoreCms.Net.Repository { } + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + + public async Task GetUserCountAsync(int userId) + { + var count = await DbClient.Queryable((gb, goods) => + new JoinQueryInfos(JoinType.Left, gb.goodsId == goods.id)) + .Where((gb, goods) => goods.isDel == false && goods.isMarketable == true && gb.userId == userId).With(SqlWith.NoLock).CountAsync(); + return count; + } + + /// /// 重写根据条件查询分页数据 /// @@ -46,6 +61,7 @@ namespace CoreCms.Net.Repository RefAsync totalCount = 0; var page = await DbClient.Queryable((gb, goods) => new JoinQueryInfos(JoinType.Left, gb.goodsId == goods.id)) + .Where((gb, goods) => goods.isDel == false && goods.isMarketable == true) .Select((gb, goods) => new CoreCmsGoodsBrowsing { id = gb.id, diff --git a/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs b/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs index 6a1cc164..d676f052 100644 --- a/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs +++ b/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs @@ -36,6 +36,16 @@ namespace CoreCms.Net.Services _unitOfWork = unitOfWork; } + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + public async Task GetUserCountAsync(int userId) + { + return await _dal.GetUserCountAsync(userId); + } + /// /// 重写根据条件查询分页数据 /// diff --git a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs index 0d765689..629a819c 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs @@ -839,7 +839,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers //订单数量 var orderCount = await _orderServices.OrderCount(0, user.id); //足迹 - var footPrintCount = await _goodsBrowsingServices.GetCountAsync(p => p.userId == user.id); + var footPrintCount = await _goodsBrowsingServices.GetUserCountAsync(user.id); //收藏 var collectionCount = await _goodsCollectionServices.GetCountAsync(p => p.userId == user.id);