using AutoMapper; using AutoMapper.QueryableExtensions; using IRaCIS.Core.Infrastructure.ExpressionExtend; using IRaCIS.Application.Interfaces; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Mvc; using Panda.DynamicWebApi.Attributes; namespace IRaCIS.Application.Services { [ ApiExplorerSettings(GroupName = "Financial")] public class VolumeRewardService : BaseService, IVolumeRewardService { private readonly IRepository _volumeRewardRepository; public VolumeRewardService(IRepository volumeRewardRepository,IMapper mapper) { _volumeRewardRepository = volumeRewardRepository; } /// /// 批量添加或更新奖励费用单价 /// [NonDynamicMethod] public async Task AddOrUpdateVolumeRewardPriceList(IEnumerable addOrUpdateModel) { await _volumeRewardRepository.BatchDeleteAsync(t => t.Id != Guid.Empty); var temp = _mapper.Map>(addOrUpdateModel); await _volumeRewardRepository.AddRangeAsync(temp); var success = await _volumeRewardRepository.SaveChangesAsync(); return ResponseOutput.Result(success); } /// /// 获取所有奖励单价列表-用于计算时,一次性获取所有 /// [NonDynamicMethod] public async Task> GetVolumeRewardPriceList() { return await _volumeRewardRepository.ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.Min).ToListAsync(); } /// /// 分页获取奖励单价列表 /// [HttpPost] public async Task> GetVolumeRewardPriceList(AwardPriceQueryDTO queryParam) { var awardPriceQueryable = _volumeRewardRepository.ProjectTo(_mapper.ConfigurationProvider); return await awardPriceQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, "Min"); } } }