using IRaCIS.Api.Filter;
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
namespace IRaCIS.Api.Controllers.Pay
{
///
/// Financial 支撑信息---工作量奖励标准
///
[Route("volumeReward")]
[ApiController, Authorize, ApiExplorerSettings(GroupName = "Financial")]
public class VolumeRewardController : ControllerBase
{
private readonly IVolumeRewardService _volumeRewardService;
private readonly ICalculateService _calculateService;
public VolumeRewardController(IVolumeRewardService volumeRewardService,
ICalculateService calculateService)
{
_volumeRewardService = volumeRewardService;
_calculateService = calculateService;
}
///
/// 批量更新奖励费用[AUTH]
///
[LogFilter]
[HttpPost, Route("addOrUpdatevolumeRewardPriceList")]
public IResponseOutput AddOrUpdateAwardPriceList(IEnumerable addOrUpdateModel)
{
var userId = User.FindFirst("id").Value;
var result = _volumeRewardService.AddOrUpdateVolumeRewardPriceList(addOrUpdateModel, Guid.Parse(userId));
var calcList = _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty);
foreach (var item in calcList)
{
if (item != null)
{
_calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO()
{
NeedCalculateReviewers = new List()
{
item.DoctorId
},
CalculateMonth = DateTime.Parse(item.YearMonth)
}, User.FindFirst("id").Value);
}
}
return result;
}
///
/// 分页获取奖励单价列表
///
[HttpPost, Route("getVolumeRewardPriceList")]
public IResponseOutput> GetAwardPriceList(AwardPriceQueryDTO queryParam)
{
return ResponseOutput.Ok(_volumeRewardService.GetVolumeRewardPriceList(queryParam));
}
}
}