88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
using Infrastructure.Attribute;
|
|
using Microsoft.AspNetCore.Http;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.Carts;
|
|
using ARW.Service.Api.IBusinessService.Carts;
|
|
using ARW.Model.Dto.Api.Carts;
|
|
using ARW.Model.Models.Business.Carts;
|
|
using ARW.Model.Vo.Api.Carts;
|
|
using ARW.Model.Models.Business.Custom.Customers;
|
|
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
|
using ARW.Model.Models.Business.ShopManager.Shops;
|
|
using Org.BouncyCastle.Crypto.Prng;
|
|
using ARW.Repository.Business.ShopManager.Shops;
|
|
|
|
namespace ARW.Service.Api.BusinessService.Carts
|
|
{
|
|
/// <summary>
|
|
/// 购物车记录接口实现类Api
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-07-20
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(ICartServiceApi), ServiceLifetime = LifeTime.Transient)]
|
|
public class CartServiceImplApi : BaseService<Cart>, ICartServiceApi
|
|
{
|
|
private readonly CartRepository _CartRepository;
|
|
private readonly ShopRepository _ShopRepository;
|
|
|
|
public CartServiceImplApi(CartRepository CartRepository, ShopRepository shopRepository)
|
|
{
|
|
this._CartRepository = CartRepository;
|
|
_ShopRepository = shopRepository;
|
|
}
|
|
|
|
#region Api接口代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询购物车记录列表(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<CartVoApi>> GetCartListApi(CartQueryDtoApi parm)
|
|
{
|
|
// 找到当前客户的所有购物车列表
|
|
var customerCartList = await _CartRepository.GetListAsync(s => s.CustomerGuid == parm.CustomerGuid);
|
|
|
|
// 找到店铺的Guids
|
|
var sameShopGuids = customerCartList.Select(item => item.ShopGuid).Distinct().ToList();
|
|
|
|
var res = new List<CartVoApi>();
|
|
// 循环每个店铺中的购物车记录
|
|
foreach (var item in sameShopGuids)
|
|
{
|
|
var shop = await _ShopRepository.GetFirstAsync(s => s.ShopGuid == item);
|
|
var shopCart = new CartVoApi();
|
|
shopCart.StoreId = shop.ShopGuid;
|
|
shopCart.StoreName = shop.ShopName;
|
|
|
|
// 查找当前用户的优惠券
|
|
//var coupon =
|
|
|
|
foreach (var _item in customerCartList)
|
|
{
|
|
if (_item.ShopGuid == shop.ShopGuid)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|