CostCalculationItem/IRaCIS.Core.API/Controllers/Financial/TrialPaymentPriceController.cs

98 lines
3.7 KiB
C#

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
{
/// <summary>
/// Financial 支撑信息---项目费用
/// </summary>
[Route("trialPaymentPrice")]
[ApiController, Authorize, ApiExplorerSettings(GroupName = "Financial")]
public class TrialPaymentPriceController : ControllerBase
{
private readonly ITrialPaymentPriceService _trialPaymentPriceService;
private readonly ICalculateService _calculateService;
private readonly ITrialService _trialService;
public TrialPaymentPriceController(ITrialPaymentPriceService trialPaymentPriceService,
ICalculateService calculateService,
ITrialService trialService)
{
_trialPaymentPriceService = trialPaymentPriceService;
_calculateService = calculateService;
_trialService = trialService;
}
/// <summary>
/// 保存(替换)项目支付价格信息(会触发没有被锁定的费用计算)[AUTH]
/// </summary>
[HttpPost, Route("addOrUpdateTrialPaymentPrice")]
public IResponseOutput AddOrUpdateTrialPaymentPrice(TrialPaymentPriceCommand addOrUpdateModel)
{
var userId = Guid.Parse(User.FindFirst("id").Value);
var result = _trialPaymentPriceService.AddOrUpdateTrialPaymentPrice(addOrUpdateModel, userId);
var needCalReviewerIds = _trialService.GetTrialEnrollmentReviewerIds(addOrUpdateModel.TrialId);
var calcList = _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty);
foreach (var item in calcList)
{
if (item != null && needCalReviewerIds.Contains(item.DoctorId))
{
_calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO()
{
NeedCalculateReviewers = new List<Guid>()
{
item.DoctorId
},
CalculateMonth = DateTime.Parse(item.YearMonth)
}, User.FindFirst("id").Value);
}
}
return result;
}
/// <summary>
/// 更新项目SOW 协议 [AUTH]
/// </summary>
/// <param name="trialSowPath"></param>
/// <returns></returns>
[HttpPost, Route("uploadTrialSOW")]
public IResponseOutput UploadTrialSOW(TrialSOWPathDTO trialSowPath)
{
var userId = Guid.Parse(User.FindFirst("id").Value);
return _trialPaymentPriceService.UploadTrialSOW(userId, trialSowPath);
}
/// <summary>
///删除项目SOW [AUTH]
/// </summary>
/// <param name="trialSowPath"></param>
/// <returns></returns>
[HttpPost, Route("deleteTrialSOW")]
public IResponseOutput DeleteTrialSOW(DeleteSowPathDTO trialSowPath)
{
var userId = Guid.Parse(User.FindFirst("id").Value);
return _trialPaymentPriceService.DeleteTrialSOW(userId, trialSowPath);
}
/// <summary>
/// 获取项目支付价格信息列表
/// </summary>
[HttpPost, Route("getTrialPaymentPriceList")]
public IResponseOutput<PageOutput<TrialPaymentPriceDTO>> GetTrialPaymentPriceList(TrialPaymentPriceQueryDTO queryParam)
{
return ResponseOutput.Ok(_trialPaymentPriceService.GetTrialPaymentPriceList(queryParam)) ;
}
}
}