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.GoodsManager.GoodsServicess; using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess; using ARW.Model.Dto.Business.GoodsManager.GoodsServicess; using ARW.Model.Models.Business.GoodsManager.GoodsServicess; using ARW.Model.Vo.Business.GoodsManager.GoodsServicess; using ARW.Model.Models.Business.ShopManager.Shops; namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsServicess { /// /// 商品服务与承诺接口实现类 /// /// @author 黎文豪 /// @date 2023-06-18 /// [AppService(ServiceType = typeof(IGoodsServicesService), ServiceLifetime = LifeTime.Transient)] public class GoodsServicesServiceImpl : BaseService, IGoodsServicesService { private readonly GoodsServicesRepository _GoodsServicesRepository; public GoodsServicesServiceImpl(GoodsServicesRepository GoodsServicesRepository) { this._GoodsServicesRepository = GoodsServicesRepository; } #region 业务逻辑代码 /// /// 查询商品服务与承诺分页列表 /// public async Task> GetGoodsServicesList(GoodsServicesQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); predicate = predicate.AndIF(parm.ShopGuid != 0, s => s.ShopGuid == parm.ShopGuid); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsServicesName), s => s.GoodsServicesName.Contains(parm.GoodsServicesName)); predicate = predicate.AndIF(parm.GoodsServicesIsDefault != null, s => s.GoodsServicesIsDefault == parm.GoodsServicesIsDefault); predicate = predicate.AndIF(parm.GoodsServicesDisplayStatus != null, s => s.GoodsServicesDisplayStatus == parm.GoodsServicesDisplayStatus); var query = _GoodsServicesRepository .Queryable() .LeftJoin((s,c) => s.ShopGuid == c.ShopGuid) .Where(predicate.ToExpression()) .WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s,c) => c.ShopName.Contains(parm.ShopName)) .OrderBy(s => s.GoodsServicesSort, OrderByType.Asc) .Select((s,c) => new GoodsServicesVo { ShopName = c.ShopName, GoodsServicesId = s.GoodsServicesId, GoodsServicesGuid = s.GoodsServicesGuid, ShopGuid = s.ShopGuid, GoodsServicesName = s.GoodsServicesName, GoodsServicesSummary = s.GoodsServicesSummary, GoodsServicesIsDefault = s.GoodsServicesIsDefault, GoodsServicesDisplayStatus = s.GoodsServicesDisplayStatus, GoodsServicesSort = s.GoodsServicesSort, }); return await query.ToPageAsync(parm); } /// /// 添加或修改商品服务与承诺 /// public async Task AddOrUpdateGoodsServices(GoodsServices model) { if (model.GoodsServicesId != 0) { var response = await _GoodsServicesRepository.UpdateAsync(model); return "修改成功!"; } else { var response = await _GoodsServicesRepository.InsertReturnSnowflakeIdAsync(model); return "添加成功!"; } } #region Excel处理 /// /// Excel数据导出处理 /// public async Task> HandleExportData(List data) { return data; } #endregion #endregion } }