mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:43:26 +08:00
【新增】新增仿点餐模块
This commit is contained in:
@@ -35,19 +35,45 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetCountAsync(int userId)
|
||||
{
|
||||
var count = DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) =>
|
||||
var count = await DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) =>
|
||||
new object[]
|
||||
{
|
||||
JoinType.Inner, cart.productId == products.id,
|
||||
JoinType.Inner, products.goodsId == goods.id
|
||||
})
|
||||
.Where((cart, products, goods) => cart.type == (int) GlobalEnumVars.OrderType.Common)
|
||||
.Select((cart, products, goods) => new {cart.id, cart.userId, goodId = goods.id})
|
||||
.Where((cart, products, goods) => cart.type == (int)GlobalEnumVars.OrderType.Common)
|
||||
.Select((cart, products, goods) => new { cart.id, cart.userId, goodId = goods.id })
|
||||
.MergeTable()
|
||||
.CountAsync(p => p.userId == userId);
|
||||
return await count;
|
||||
return count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 获取购物车商品总价格
|
||||
|
||||
/// <summary>
|
||||
/// 获取购物车商品总价格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal> GetMoneyAsync(int userId)
|
||||
{
|
||||
var count = await DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) =>
|
||||
new object[]
|
||||
{
|
||||
JoinType.Inner, cart.productId == products.id,
|
||||
JoinType.Inner, products.goodsId == goods.id
|
||||
})
|
||||
.Where((cart, products, goods) => cart.type == (int)GlobalEnumVars.OrderType.Common && cart.userId == userId)
|
||||
.Select((cart, products, goods) => new { cart.nums, products.price, sunMoney = cart.nums * products.price })
|
||||
.MergeTable()
|
||||
.SumAsync(p => p.sunMoney);
|
||||
return count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user