98 lines
2.7 KiB
C#
98 lines
2.7 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 Infrastructure;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.Carts;
|
|
using ARW.Service.Business.IBusinessService.Carts;
|
|
using ARW.Model.Dto.Business.Carts;
|
|
using ARW.Model.Models.Business.Carts;
|
|
using ARW.Model.Vo.Business.Carts;
|
|
using ARW.Model.Dto.Api.Carts;
|
|
|
|
namespace ARW.Service.Business.BusinessService.Carts
|
|
{
|
|
/// <summary>
|
|
/// 购物车记录接口实现类
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-07-20
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(ICartService), ServiceLifetime = LifeTime.Transient)]
|
|
public class CartServiceImpl : BaseService<Cart>, ICartService
|
|
{
|
|
private readonly CartRepository _CartRepository;
|
|
|
|
public CartServiceImpl(CartRepository CartRepository)
|
|
{
|
|
this._CartRepository = CartRepository;
|
|
}
|
|
|
|
#region 业务逻辑代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询购物车记录分页列表
|
|
/// </summary>
|
|
public async Task<PagedInfo<CartVo>> GetCartList(CartQueryDto parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<Cart>();
|
|
|
|
predicate = predicate.AndIF(parm.CustomerGuid != null, s => s.CustomerGuid == parm.CustomerGuid);
|
|
predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
|
|
var query = _CartRepository
|
|
.Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
|
.Select(s => new CartVo
|
|
{
|
|
CartId = s.CartId,
|
|
CartGuid = s.CartGuid,
|
|
CustomerGuid = s.CustomerGuid,
|
|
ShopGuid = s.ShopGuid,
|
|
//GoodsGud = s.GoodsGud,
|
|
GoodsSkuId = s.GoodsSkuId,
|
|
CartGoodsNum = s.CartGoodsNum,
|
|
});
|
|
|
|
|
|
return await query.ToPageAsync(parm);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改购物车记录
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateCart(Cart model)
|
|
{
|
|
if (model.CartId != 0)
|
|
{
|
|
var response = await _CartRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
|
|
var response = await _CartRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
#region Excel处理
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|