From dc968efd1b121fd8cfd5d7d8be124334208f74b0 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Tue, 26 Apr 2022 17:50:48 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=93=E5=82=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Financial/PaymentAdjustmentService.cs | 67 ++++++++++++-------
.../Financial/ReviewerPayInfoService.cs | 8 +--
.../Financial/TrialPaymentPriceService.cs | 9 ++-
.../Financial/TrialRevenuesPriceService.cs | 4 +-
.../Service/WorkLoad/DoctorWorkloadService.cs | 10 ++-
.../Service/WorkLoad/EnrollService.cs | 11 ++-
.../Repository/ICommandRepository.cs | 4 +-
7 files changed, 64 insertions(+), 49 deletions(-)
diff --git a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs
index 1935003e4..2cd692e76 100644
--- a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs
+++ b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs
@@ -2,10 +2,6 @@
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts.Pay;
using IRaCIS.Core.Domain.Share;
-using IRaCIS.Core.Application.Filter;
-using IRaCIS.Core.Infra.EFCore;
-using IRaCIS.Core.Domain.Models;
-using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Mvc;
using Panda.DynamicWebApi.Attributes;
@@ -33,7 +29,7 @@ namespace IRaCIS.Application.Services
///
/// 添加或更新费用调整[AUTH]
///
-
+
[HttpPost]
public async Task AddOrUpdatePaymentAdjustment(PaymentAdjustmentCommand addOrUpdateModel)
{
@@ -85,7 +81,13 @@ namespace IRaCIS.Application.Services
payment.AdjustmentCNY += costAdjustment.AdjustmentCNY;
payment.AdjustmentUSD += costAdjustment.AdjustmentUSD;
- await _paymentRepository.UpdateAsync(payment);
+ //await _paymentRepository.UpdateAsync(payment);
+
+ await _paymentRepository.UpdateAsync(payment, u => new Payment()
+ {
+ AdjustmentCNY = payment.AdjustmentCNY + costAdjustment.AdjustmentCNY,
+ AdjustmentUSD = payment.AdjustmentUSD + costAdjustment.AdjustmentUSD
+ });
await _payAdjustmentRepository.SaveChangesAsync();
@@ -95,7 +97,11 @@ namespace IRaCIS.Application.Services
}
else
{
+
+
+
// 更新的时候,先查出来,更新前的调整费用数据
+
var paymentAdjust = await _payAdjustmentRepository.FirstOrDefaultAsync(t => t.Id == addOrUpdateModel.Id);
@@ -105,7 +111,8 @@ namespace IRaCIS.Application.Services
paymentAdjust.AdjustmentUSD = addOrUpdateModel.AdjustPaymentUSD;
paymentAdjust.AdjustmentCNY = addOrUpdateModel.AdjustPaymentUSD * (exchangeRate?.Rate ?? 0);
- await _payAdjustmentRepository.UpdateAsync(paymentAdjust);
+ //await _payAdjustmentRepository.UpdateAsync(paymentAdjust);
+
var success = await _payAdjustmentRepository.SaveChangesAsync();
if (success)
@@ -113,13 +120,19 @@ namespace IRaCIS.Application.Services
var adjustmentList = await _payAdjustmentRepository.Where(u => u.ReviewerId == addOrUpdateModel.ReviewerId && u.YearMonth == yearMonth).ToListAsync();
- payment.AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY);
- payment.AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD);
+ await _paymentRepository.UpdateAsync(payment, u => new Payment()
+ {
+ AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY),
+ AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD)
+ });
- await _paymentRepository.UpdateAsync(payment);
+ //payment.AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY);
+ //payment.AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD);
- await _paymentRepository.SaveChangesAsync();
+ //await _paymentRepository.UpdateAsync(payment);
+
+ await _paymentRepository.SaveChangesAsync();
}
//查询得到历史汇总
@@ -171,17 +184,15 @@ namespace IRaCIS.Application.Services
///
/// 删除费用调整记录
///
-
+
[HttpDelete("{id:guid}")]
public async Task DeletePaymentAdjustment(Guid id)
{
var adjustPayment = await _payAdjustmentRepository.FirstOrDefaultAsync(u => u.Id == id);
- var monthPay = await _paymentRepository.FirstOrDefaultAsync(t =>
- t.DoctorId == adjustPayment.ReviewerId && t.YearMonth == adjustPayment.YearMonth);
await _payAdjustmentRepository.DeleteAsync(new PaymentAdjustment() { Id = id });
-
+
var success = await _payAdjustmentRepository.SaveChangesAsync();
if (success)
@@ -190,12 +201,22 @@ namespace IRaCIS.Application.Services
var adjustmentList = await _payAdjustmentRepository.Where(u =>
u.ReviewerId == adjustPayment.ReviewerId && u.YearMonth == adjustPayment.YearMonth).ToListAsync();
- monthPay.AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY);
- monthPay.AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD);
+
+ var monthPay = await _paymentRepository.FirstOrDefaultAsync(t =>
+ t.DoctorId == adjustPayment.ReviewerId && t.YearMonth == adjustPayment.YearMonth);
- await _paymentRepository.UpdateAsync(monthPay);
+ await _paymentRepository.UpdateAsync(monthPay, u => new Payment()
+ {
+ AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY),
+ AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD)
+ });
+
+
+ //monthPay.AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY);
+ //monthPay.AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD);
+ //await _paymentRepository.UpdateAsync(monthPay);
await _paymentRepository.SaveChangesAsync();
}
@@ -277,13 +298,13 @@ namespace IRaCIS.Application.Services
foreach (var reviewer in needUpdatePayment)
{
- await _paymentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth &&
+ await _paymentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth &&
!u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment()
- {
- AdjustmentUSD = reviewer.AdjustUSD,
- AdjustmentCNY = reviewer.AdjustCNY
+ {
+ AdjustmentUSD = reviewer.AdjustUSD,
+ AdjustmentCNY = reviewer.AdjustCNY
- });
+ });
}
diff --git a/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs b/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs
index f95713b34..9a002e74a 100644
--- a/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs
+++ b/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs
@@ -36,15 +36,13 @@ namespace IRaCIS.Application.Services
var doctorPayInfoExistedItem = await _doctorPayInfoRepository.FirstOrDefaultAsync(u => u.DoctorId == addOrUpdateModel.DoctorId);
if (doctorPayInfoExistedItem == null)//insert
{
- var doctorPayInfo = _mapper.Map(addOrUpdateModel);
- //doctorPayInfo.CreateTime = DateTime.Now;
- //doctorPayInfo.CreateUserId = userId;
- await _doctorPayInfoRepository.AddAsync(doctorPayInfo);
+
+ await _doctorPayInfoRepository.InsertFromDTOAsync(addOrUpdateModel);
}
else//update
{
- await _doctorPayInfoRepository.UpdateAsync(_mapper.Map(addOrUpdateModel, doctorPayInfoExistedItem));
+ await _doctorPayInfoRepository.UpdateFromDTOAsync(addOrUpdateModel);
}
success = await _doctorPayInfoRepository.SaveChangesAsync();
diff --git a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs
index 7e36a2e0a..3f8091bdf 100644
--- a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs
+++ b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs
@@ -40,14 +40,13 @@ namespace IRaCIS.Application.Services
var trialExistedItem = await _trialExtRepository.FirstOrDefaultAsync(u => u.TrialId == addOrUpdateModel.TrialId);
if (trialExistedItem == null)//insert
{
- var trialExt = _mapper.Map(addOrUpdateModel);
- await _trialExtRepository.AddAsync(trialExt);
+ await _trialExtRepository.InsertFromDTOAsync(addOrUpdateModel);
}
else//update
{
- await _trialExtRepository.UpdateAsync(_mapper.Map(addOrUpdateModel, trialExistedItem));
+ await _trialExtRepository.UpdateFromDTOAsync(addOrUpdateModel);
}
var success = await _trialExtRepository.SaveChangesAsync();
@@ -62,11 +61,11 @@ namespace IRaCIS.Application.Services
if (trialPaymentPrice == null)//添加
{
- await _trialExtRepository.AddAsync(_mapper.Map(trialSowPath));
+ await _trialExtRepository.InsertFromDTOAsync(trialSowPath);
}
else//更新
{
- await _trialExtRepository.UpdateAsync(_mapper.Map(trialSowPath, trialPaymentPrice));
+ await _trialExtRepository.UpdateFromDTOAsync(trialSowPath);
}
var success = await _trialExtRepository.SaveChangesAsync();
diff --git a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs
index 705a04b46..adb00b5a8 100644
--- a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs
+++ b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs
@@ -57,9 +57,9 @@ namespace IRaCIS.Application.Services
}
else//update
{
- var trialRevenuesPrice = (await _trialRevenuesPriceRepository.AsQueryable().FirstOrDefaultAsync(u => u.TrialId == model.TrialId)).IfNullThrowException();
+ //var trialRevenuesPrice = (await _trialRevenuesPriceRepository.AsQueryable().FirstOrDefaultAsync(u => u.TrialId == model.TrialId)).IfNullThrowException();
- await _trialRevenuesPriceRepository.UpdateAsync(_mapper.Map(model, trialRevenuesPrice));
+ await _trialRevenuesPriceRepository.UpdateFromDTOAsync(model);
// 完善价格的 将对应的列设置为true 变更为有价格了
diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs
index e0b325fa8..1b4bc0494 100644
--- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs
+++ b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs
@@ -54,20 +54,18 @@ namespace IRaCIS.Application.Services
ReviewerAckDTO attachmentViewModel)
{
- var intoGroupItem = await _enrollRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.DoctorId == attachmentViewModel.DoctorId);
+ var intoGroupItem = (await _enrollRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.DoctorId == attachmentViewModel.DoctorId)).IfNullThrowException();
- if (intoGroupItem == null) return Null404NotFound(intoGroupItem);
if (attachmentViewModel.Id != Guid.Empty)
{
await _attachmentRepository.BatchDeleteNoTrackingAsync(t => t.Id == attachmentViewModel.Id);
}
- var attach = _mapper.Map(attachmentViewModel);
- var attachment = await _attachmentRepository.AddAsync(attach);
+ var attachment = await _attachmentRepository.InsertFromDTOAsync(attachmentViewModel);
- intoGroupItem.AttachmentId = attachment.Id;
- await _enrollRepository.UpdateAsync(intoGroupItem);
+ //intoGroupItem.AttachmentId = attachment.Id;
+ await _enrollRepository.UpdateNoQueryAsync(intoGroupItem.Id,u=>new Enroll(){AttachmentId = attachment.Id});
var success = await _enrollRepository.SaveChangesAsync();
diff --git a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs
index bab9fcb5e..e91dddf17 100644
--- a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs
+++ b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs
@@ -50,12 +50,11 @@ namespace IRaCIS.Application.Services
var trialDoctoritem = await _enrollRepository.FirstOrDefaultAsync(u => u.Id == addOrUpdateModel.Id);
if (trialDoctoritem == null)//insert
{
- var trialExt = _mapper.Map(addOrUpdateModel);
- await _enrollRepository.AddAsync(trialExt);
+ await _enrollRepository.InsertFromDTOAsync(addOrUpdateModel);
}
else//update
{
- await _enrollRepository.UpdateAsync(_mapper.Map(addOrUpdateModel, trialDoctoritem));
+ await _enrollRepository.UpdateFromDTOAsync(addOrUpdateModel);
}
var success = await _enrollRepository.SaveChangesAsync();
return ResponseOutput.Result(success);
@@ -358,7 +357,7 @@ namespace IRaCIS.Application.Services
//更新入组表
- var intoGroupList = await _enrollRepository.Where(t => t.TrialId == trialId).ToListAsync();
+ var intoGroupList = await _enrollRepository.Where(t => t.TrialId == trialId,true).ToListAsync();
if (confirmState == 1) //确认入组
{
@@ -368,7 +367,7 @@ namespace IRaCIS.Application.Services
{
intoGroupItem.EnrollStatus = (int)EnrollStatus.ConfirmIntoGroup;
intoGroupItem.EnrollTime = DateTime.Now;
- await _enrollRepository.UpdateAsync(intoGroupItem);
+
await _enrollDetailRepository.AddAsync(new EnrollDetail()
{
@@ -389,7 +388,6 @@ namespace IRaCIS.Application.Services
{
intoGroupItem.EnrollStatus = (int)EnrollStatus.InviteIntoGroup;
intoGroupItem.EnrollTime = null;
- await _enrollRepository.UpdateAsync(intoGroupItem);
var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t =>
@@ -434,7 +432,6 @@ namespace IRaCIS.Application.Services
intoGroupItem.EnrollStatus = (int)EnrollStatus.InviteIntoGroup;
intoGroupItem.EnrollTime = null;
- await _enrollRepository.UpdateAsync(intoGroupItem);
var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t =>
t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId &&
diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs
index 641441743..5a7b7c415 100644
--- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs
+++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs
@@ -79,7 +79,9 @@ namespace IRaCIS.Core.Infra.EFCore
//Task AddRangeAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default);
// 不建议使用,使用跟踪,然后save 部分字段更新,此种方式是更新所有字段
- Task UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
+ //Task UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
+
+
Task SaveChangesAsync(CancellationToken cancellationToken = default);
Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);