65 lines
2.6 KiB
C#
65 lines
2.6 KiB
C#
using AutoMapper;
|
|
using AutoMapper.QueryableExtensions;
|
|
using IRaCIS.Application.ExpressionExtend;
|
|
using IRaCIS.Application.Interfaces;
|
|
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
|
using IRaCIS.Core.Domain.Share;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using IRaCIS.Core.Domain.Interfaces;
|
|
using IRaCIS.Core.Domain.Models;
|
|
|
|
namespace IRaCIS.Application.Services.Pay
|
|
{
|
|
public class VolumeRewardService : IVolumeRewardService
|
|
{
|
|
private readonly IVolumeRewardRepository _volumeRewardRepository;
|
|
private readonly IMapper _mapper;
|
|
|
|
public VolumeRewardService(IVolumeRewardRepository volumeRewardRepository,IMapper mapper)
|
|
{
|
|
_volumeRewardRepository = volumeRewardRepository;
|
|
_mapper = mapper;
|
|
}
|
|
/// <summary>
|
|
/// 批量添加或更新奖励费用单价
|
|
/// </summary>
|
|
public IResponseOutput AddOrUpdateVolumeRewardPriceList(IEnumerable<AwardPriceCommand> addOrUpdateModel, Guid userId)
|
|
{
|
|
_volumeRewardRepository.Delete(t => t.Id != Guid.Empty);
|
|
var temp = _mapper.Map<List<VolumeReward>>(addOrUpdateModel);
|
|
foreach (var item in temp)
|
|
{
|
|
item.CreateUserId = userId;
|
|
item.CreateTime = DateTime.Now;
|
|
}
|
|
_volumeRewardRepository.AddRange(temp);
|
|
var success = _volumeRewardRepository.SaveChanges();
|
|
|
|
return ResponseOutput.Result(success, success ? string.Empty : StaticData.UpdateFailed);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取所有奖励单价列表-用于计算时,一次性获取所有
|
|
/// </summary>
|
|
public List<AwardPriceCalculateDTO> GetVolumeRewardPriceList()
|
|
{
|
|
return _volumeRewardRepository.GetAll().ProjectTo<AwardPriceCalculateDTO>(_mapper.ConfigurationProvider).OrderBy(t => t.Min).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页获取奖励单价列表
|
|
/// </summary>
|
|
public PageOutput<AwardPriceDTO> GetVolumeRewardPriceList(AwardPriceQueryDTO queryParam)
|
|
{
|
|
var awardPriceQueryable = _volumeRewardRepository.GetAll().ProjectTo<AwardPriceDTO>(_mapper.ConfigurationProvider);
|
|
awardPriceQueryable = awardPriceQueryable.OrderBy("Min");
|
|
var count = awardPriceQueryable.Count();
|
|
awardPriceQueryable = awardPriceQueryable.Skip((queryParam.PageIndex - 1) * queryParam.PageSize)
|
|
.Take(queryParam.PageSize);
|
|
var list = awardPriceQueryable.ToList();
|
|
return new PageOutput<AwardPriceDTO>(queryParam.PageIndex, queryParam.PageSize, count, list);
|
|
}
|
|
}
|
|
} |