mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-04 19:39:48 +08:00
接口端【优化】:优化接口端提供给小程序显示的销量数据。
This commit is contained in:
@@ -241,5 +241,16 @@ namespace CoreCms.Net.IRepository
|
|||||||
Expression<Func<GoodListDTO, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false,
|
Expression<Func<GoodListDTO, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false,
|
||||||
bool isDataCache = false, int cacheTimes = int.MaxValue);
|
bool isDataCache = false, int cacheTimes = int.MaxValue);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取单个商品的销售数量
|
||||||
|
/// <summary>
|
||||||
|
/// 获取单个商品的销售数量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="goodId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> QueryOneGoodSalesVolume(int goodId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2221,7 +2221,7 @@ namespace CoreCms.Net.Repository
|
|||||||
unit = good.unit,
|
unit = good.unit,
|
||||||
commentsCount = good.commentsCount,
|
commentsCount = good.commentsCount,
|
||||||
viewCount = good.viewCount,
|
viewCount = good.viewCount,
|
||||||
buyCount = SqlFunc.Subqueryable<CoreCmsOrderItem>()
|
buyCount = good.initialSales + SqlFunc.Subqueryable<CoreCmsOrderItem>()
|
||||||
.LeftJoin<CoreCmsOrder>((sOrderItem, sOrder) => sOrder.orderId == sOrderItem.orderId)
|
.LeftJoin<CoreCmsOrder>((sOrderItem, sOrder) => sOrder.orderId == sOrderItem.orderId)
|
||||||
.Where((sOrderItem, sOrder) => sOrderItem.goodsId == good.id && (sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes || sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
|
.Where((sOrderItem, sOrder) => sOrderItem.goodsId == good.id && (sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes || sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
|
||||||
.Sum((sOrderItem, sOrder) => sOrderItem.nums),
|
.Sum((sOrderItem, sOrder) => sOrderItem.nums),
|
||||||
@@ -2265,7 +2265,7 @@ namespace CoreCms.Net.Repository
|
|||||||
unit = good.unit,
|
unit = good.unit,
|
||||||
commentsCount = good.commentsCount,
|
commentsCount = good.commentsCount,
|
||||||
viewCount = good.viewCount,
|
viewCount = good.viewCount,
|
||||||
buyCount = SqlFunc.Subqueryable<CoreCmsOrderItem>()
|
buyCount = good.initialSales + SqlFunc.Subqueryable<CoreCmsOrderItem>()
|
||||||
.LeftJoin<CoreCmsOrder>((sOrderItem, sOrder) => sOrder.orderId == sOrderItem.orderId)
|
.LeftJoin<CoreCmsOrder>((sOrderItem, sOrder) => sOrder.orderId == sOrderItem.orderId)
|
||||||
.Where((sOrderItem, sOrder) => sOrderItem.goodsId == good.id && (sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes || sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
|
.Where((sOrderItem, sOrder) => sOrderItem.goodsId == good.id && (sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes || sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
|
||||||
.Sum((sOrderItem, sOrder) => sOrderItem.nums),
|
.Sum((sOrderItem, sOrder) => sOrderItem.nums),
|
||||||
@@ -2404,5 +2404,26 @@ namespace CoreCms.Net.Repository
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 获取单个商品的销售数量
|
||||||
|
/// <summary>
|
||||||
|
/// 获取单个商品的销售数量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="goodId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> QueryOneGoodSalesVolume(int goodId)
|
||||||
|
{
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
count = await DbClient.Queryable<CoreCmsOrderItem>()
|
||||||
|
.LeftJoin<CoreCmsOrder>((sOrderItem, sOrder) => sOrder.orderId == sOrderItem.orderId)
|
||||||
|
.Where((sOrderItem, sOrder) => sOrderItem.goodsId == goodId &&
|
||||||
|
(sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes ||
|
||||||
|
sOrder.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
|
||||||
|
.SumAsync((sOrderItem, sOrder) => sOrderItem.nums);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -583,7 +583,8 @@ namespace CoreCms.Net.Services
|
|||||||
good.brand = await _brandServices.QueryByIdAsync(good.brandId, true, true);
|
good.brand = await _brandServices.QueryByIdAsync(good.brandId, true, true);
|
||||||
|
|
||||||
//取出销量
|
//取出销量
|
||||||
good.buyCount = good.initialSales + await _orderItemServices.GetSumAsync(p => p.goodsId == good.id, o => o.nums, true);
|
good.buyCount = good.initialSales + await _dal.QueryOneGoodSalesVolume(good.id);
|
||||||
|
|
||||||
return good;
|
return good;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user