112 lines
4.0 KiB
C#
112 lines
4.0 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.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
|
|
{
|
|
/// <summary>
|
|
/// 商品服务与承诺接口实现类
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-06-18
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IGoodsServicesService), ServiceLifetime = LifeTime.Transient)]
|
|
public class GoodsServicesServiceImpl : BaseService<GoodsServices>, IGoodsServicesService
|
|
{
|
|
private readonly GoodsServicesRepository _GoodsServicesRepository;
|
|
|
|
public GoodsServicesServiceImpl(GoodsServicesRepository GoodsServicesRepository)
|
|
{
|
|
this._GoodsServicesRepository = GoodsServicesRepository;
|
|
}
|
|
|
|
#region 业务逻辑代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询商品服务与承诺分页列表
|
|
/// </summary>
|
|
public async Task<PagedInfo<GoodsServicesVo>> GetGoodsServicesList(GoodsServicesQueryDto parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<GoodsServices>();
|
|
|
|
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<Shop>((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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改商品服务与承诺
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateGoodsServices(GoodsServices model)
|
|
{
|
|
if (model.GoodsServicesId != 0)
|
|
{
|
|
var response = await _GoodsServicesRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
|
|
var response = await _GoodsServicesRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
#region Excel处理
|
|
|
|
|
|
/// <summary>
|
|
/// Excel数据导出处理
|
|
/// </summary>
|
|
public async Task<List<GoodsServicesVo>> HandleExportData(List<GoodsServicesVo> data)
|
|
{
|
|
return data;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|