【修复】修复商品下架或者删除后,【我的足迹】统计数据及列表不准确的问题。

【修复】修复商品下架或者删除后,【我的收藏】统计数据及列表不准确的问题。
This commit is contained in:
大灰灰
2022-12-07 01:49:30 +08:00
parent 422ece5c65
commit 090b503f8d
5 changed files with 59 additions and 2 deletions

View File

@@ -32,6 +32,23 @@ namespace CoreCms.Net.Repository
{
}
/// <summary>
/// 根据用户序列获取用户的足迹数量
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<int> GetUserCountAsync(int userId)
{
var count = await DbClient.Queryable<CoreCmsGoodsCollection, CoreCmsGoods>((gc, goods) =>
new JoinQueryInfos(JoinType.Left, gc.goodsId == goods.id))
.Where((gc, goods) => goods.isDel == false && goods.isMarketable == true && gc.userId == userId).With(SqlWith.NoLock).CountAsync();
return count;
}
#region
/// <summary>
/// 重写根据条件查询分页数据
@@ -47,7 +64,19 @@ namespace CoreCms.Net.Repository
int pageSize = 20)
{
RefAsync<int> totalCount = 0;
var page = await DbClient.Queryable<CoreCmsGoodsCollection>()
var page = await DbClient.Queryable<CoreCmsGoodsCollection, CoreCmsGoods>((gc, goods) =>
new JoinQueryInfos(JoinType.Left, gc.goodsId == goods.id))
.Where((gc, goods) => goods.isDel == false && goods.isMarketable == true)
.Select((gc, goods) => new CoreCmsGoodsCollection
{
id = gc.id,
userId = gc.userId,
goodsId = gc.goodsId,
createTime = gc.createTime,
goodsName = gc.goodsName
})
.With(SqlWith.NoLock)
.MergeTable()
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
.WhereIF(predicate != null, predicate)
.Mapper(p => p.goods, p => p.goodsId)