修改仓储

Uat_Study
hang 2022-04-26 17:50:48 +08:00
parent 9b419aafe0
commit dc968efd1b
7 changed files with 64 additions and 49 deletions

View File

@ -2,10 +2,6 @@
using IRaCIS.Application.Interfaces; using IRaCIS.Application.Interfaces;
using IRaCIS.Application.Contracts.Pay; using IRaCIS.Application.Contracts.Pay;
using IRaCIS.Core.Domain.Share; 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 Microsoft.AspNetCore.Mvc;
using Panda.DynamicWebApi.Attributes; using Panda.DynamicWebApi.Attributes;
@ -33,7 +29,7 @@ namespace IRaCIS.Application.Services
/// <summary> /// <summary>
/// 添加或更新费用调整[AUTH] /// 添加或更新费用调整[AUTH]
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public async Task<IResponseOutput> AddOrUpdatePaymentAdjustment(PaymentAdjustmentCommand addOrUpdateModel) public async Task<IResponseOutput> AddOrUpdatePaymentAdjustment(PaymentAdjustmentCommand addOrUpdateModel)
{ {
@ -85,7 +81,13 @@ namespace IRaCIS.Application.Services
payment.AdjustmentCNY += costAdjustment.AdjustmentCNY; payment.AdjustmentCNY += costAdjustment.AdjustmentCNY;
payment.AdjustmentUSD += costAdjustment.AdjustmentUSD; 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(); await _payAdjustmentRepository.SaveChangesAsync();
@ -95,7 +97,11 @@ namespace IRaCIS.Application.Services
} }
else else
{ {
// 更新的时候,先查出来,更新前的调整费用数据 // 更新的时候,先查出来,更新前的调整费用数据
var paymentAdjust = await _payAdjustmentRepository.FirstOrDefaultAsync(t => t.Id == addOrUpdateModel.Id); var paymentAdjust = await _payAdjustmentRepository.FirstOrDefaultAsync(t => t.Id == addOrUpdateModel.Id);
@ -105,7 +111,8 @@ namespace IRaCIS.Application.Services
paymentAdjust.AdjustmentUSD = addOrUpdateModel.AdjustPaymentUSD; paymentAdjust.AdjustmentUSD = addOrUpdateModel.AdjustPaymentUSD;
paymentAdjust.AdjustmentCNY = addOrUpdateModel.AdjustPaymentUSD * (exchangeRate?.Rate ?? 0); paymentAdjust.AdjustmentCNY = addOrUpdateModel.AdjustPaymentUSD * (exchangeRate?.Rate ?? 0);
await _payAdjustmentRepository.UpdateAsync(paymentAdjust); //await _payAdjustmentRepository.UpdateAsync(paymentAdjust);
var success = await _payAdjustmentRepository.SaveChangesAsync(); var success = await _payAdjustmentRepository.SaveChangesAsync();
if (success) if (success)
@ -113,13 +120,19 @@ namespace IRaCIS.Application.Services
var adjustmentList = await _payAdjustmentRepository.Where(u => u.ReviewerId == addOrUpdateModel.ReviewerId && u.YearMonth == yearMonth).ToListAsync(); 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
/// <summary> /// <summary>
/// 删除费用调整记录 /// 删除费用调整记录
/// </summary> /// </summary>
[HttpDelete("{id:guid}")] [HttpDelete("{id:guid}")]
public async Task<IResponseOutput> DeletePaymentAdjustment(Guid id) public async Task<IResponseOutput> DeletePaymentAdjustment(Guid id)
{ {
var adjustPayment = await _payAdjustmentRepository.FirstOrDefaultAsync(u => u.Id == 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 }); await _payAdjustmentRepository.DeleteAsync(new PaymentAdjustment() { Id = id });
var success = await _payAdjustmentRepository.SaveChangesAsync(); var success = await _payAdjustmentRepository.SaveChangesAsync();
if (success) if (success)
@ -190,12 +201,22 @@ namespace IRaCIS.Application.Services
var adjustmentList = await _payAdjustmentRepository.Where(u => var adjustmentList = await _payAdjustmentRepository.Where(u =>
u.ReviewerId == adjustPayment.ReviewerId && u.YearMonth == adjustPayment.YearMonth).ToListAsync(); 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(); await _paymentRepository.SaveChangesAsync();
} }
@ -277,13 +298,13 @@ namespace IRaCIS.Application.Services
foreach (var reviewer in needUpdatePayment) 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() !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment()
{ {
AdjustmentUSD = reviewer.AdjustUSD, AdjustmentUSD = reviewer.AdjustUSD,
AdjustmentCNY = reviewer.AdjustCNY AdjustmentCNY = reviewer.AdjustCNY
}); });
} }

View File

@ -36,15 +36,13 @@ namespace IRaCIS.Application.Services
var doctorPayInfoExistedItem = await _doctorPayInfoRepository.FirstOrDefaultAsync(u => u.DoctorId == addOrUpdateModel.DoctorId); var doctorPayInfoExistedItem = await _doctorPayInfoRepository.FirstOrDefaultAsync(u => u.DoctorId == addOrUpdateModel.DoctorId);
if (doctorPayInfoExistedItem == null)//insert if (doctorPayInfoExistedItem == null)//insert
{ {
var doctorPayInfo = _mapper.Map<ReviewerPayInformation>(addOrUpdateModel);
//doctorPayInfo.CreateTime = DateTime.Now; await _doctorPayInfoRepository.InsertFromDTOAsync(addOrUpdateModel);
//doctorPayInfo.CreateUserId = userId;
await _doctorPayInfoRepository.AddAsync(doctorPayInfo);
} }
else//update else//update
{ {
await _doctorPayInfoRepository.UpdateAsync(_mapper.Map(addOrUpdateModel, doctorPayInfoExistedItem)); await _doctorPayInfoRepository.UpdateFromDTOAsync(addOrUpdateModel);
} }
success = await _doctorPayInfoRepository.SaveChangesAsync(); success = await _doctorPayInfoRepository.SaveChangesAsync();

View File

@ -40,14 +40,13 @@ namespace IRaCIS.Application.Services
var trialExistedItem = await _trialExtRepository.FirstOrDefaultAsync(u => u.TrialId == addOrUpdateModel.TrialId); var trialExistedItem = await _trialExtRepository.FirstOrDefaultAsync(u => u.TrialId == addOrUpdateModel.TrialId);
if (trialExistedItem == null)//insert if (trialExistedItem == null)//insert
{ {
var trialExt = _mapper.Map<TrialPaymentPrice>(addOrUpdateModel);
await _trialExtRepository.AddAsync(trialExt); await _trialExtRepository.InsertFromDTOAsync(addOrUpdateModel);
} }
else//update else//update
{ {
await _trialExtRepository.UpdateAsync(_mapper.Map(addOrUpdateModel, trialExistedItem)); await _trialExtRepository.UpdateFromDTOAsync(addOrUpdateModel);
} }
var success = await _trialExtRepository.SaveChangesAsync(); var success = await _trialExtRepository.SaveChangesAsync();
@ -62,11 +61,11 @@ namespace IRaCIS.Application.Services
if (trialPaymentPrice == null)//添加 if (trialPaymentPrice == null)//添加
{ {
await _trialExtRepository.AddAsync(_mapper.Map<TrialPaymentPrice>(trialSowPath)); await _trialExtRepository.InsertFromDTOAsync(trialSowPath);
} }
else//更新 else//更新
{ {
await _trialExtRepository.UpdateAsync(_mapper.Map(trialSowPath, trialPaymentPrice)); await _trialExtRepository.UpdateFromDTOAsync(trialSowPath);
} }
var success = await _trialExtRepository.SaveChangesAsync(); var success = await _trialExtRepository.SaveChangesAsync();

View File

@ -57,9 +57,9 @@ namespace IRaCIS.Application.Services
} }
else//update 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 变更为有价格了 // 完善价格的 将对应的列设置为true 变更为有价格了

View File

@ -54,20 +54,18 @@ namespace IRaCIS.Application.Services
ReviewerAckDTO attachmentViewModel) 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) if (attachmentViewModel.Id != Guid.Empty)
{ {
await _attachmentRepository.BatchDeleteNoTrackingAsync(t => t.Id == attachmentViewModel.Id); await _attachmentRepository.BatchDeleteNoTrackingAsync(t => t.Id == attachmentViewModel.Id);
} }
var attach = _mapper.Map<Attachment>(attachmentViewModel); var attachment = await _attachmentRepository.InsertFromDTOAsync(attachmentViewModel);
var attachment = await _attachmentRepository.AddAsync(attach);
intoGroupItem.AttachmentId = attachment.Id; //intoGroupItem.AttachmentId = attachment.Id;
await _enrollRepository.UpdateAsync(intoGroupItem); await _enrollRepository.UpdateNoQueryAsync(intoGroupItem.Id,u=>new Enroll(){AttachmentId = attachment.Id});
var success = await _enrollRepository.SaveChangesAsync(); var success = await _enrollRepository.SaveChangesAsync();

View File

@ -50,12 +50,11 @@ namespace IRaCIS.Application.Services
var trialDoctoritem = await _enrollRepository.FirstOrDefaultAsync(u => u.Id == addOrUpdateModel.Id); var trialDoctoritem = await _enrollRepository.FirstOrDefaultAsync(u => u.Id == addOrUpdateModel.Id);
if (trialDoctoritem == null)//insert if (trialDoctoritem == null)//insert
{ {
var trialExt = _mapper.Map<Enroll>(addOrUpdateModel); await _enrollRepository.InsertFromDTOAsync(addOrUpdateModel);
await _enrollRepository.AddAsync(trialExt);
} }
else//update else//update
{ {
await _enrollRepository.UpdateAsync(_mapper.Map(addOrUpdateModel, trialDoctoritem)); await _enrollRepository.UpdateFromDTOAsync(addOrUpdateModel);
} }
var success = await _enrollRepository.SaveChangesAsync(); var success = await _enrollRepository.SaveChangesAsync();
return ResponseOutput.Result(success); 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) //确认入组 if (confirmState == 1) //确认入组
{ {
@ -368,7 +367,7 @@ namespace IRaCIS.Application.Services
{ {
intoGroupItem.EnrollStatus = (int)EnrollStatus.ConfirmIntoGroup; intoGroupItem.EnrollStatus = (int)EnrollStatus.ConfirmIntoGroup;
intoGroupItem.EnrollTime = DateTime.Now; intoGroupItem.EnrollTime = DateTime.Now;
await _enrollRepository.UpdateAsync(intoGroupItem);
await _enrollDetailRepository.AddAsync(new EnrollDetail() await _enrollDetailRepository.AddAsync(new EnrollDetail()
{ {
@ -389,7 +388,6 @@ namespace IRaCIS.Application.Services
{ {
intoGroupItem.EnrollStatus = (int)EnrollStatus.InviteIntoGroup; intoGroupItem.EnrollStatus = (int)EnrollStatus.InviteIntoGroup;
intoGroupItem.EnrollTime = null; intoGroupItem.EnrollTime = null;
await _enrollRepository.UpdateAsync(intoGroupItem);
var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t => var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t =>
@ -434,7 +432,6 @@ namespace IRaCIS.Application.Services
intoGroupItem.EnrollStatus = (int)EnrollStatus.InviteIntoGroup; intoGroupItem.EnrollStatus = (int)EnrollStatus.InviteIntoGroup;
intoGroupItem.EnrollTime = null; intoGroupItem.EnrollTime = null;
await _enrollRepository.UpdateAsync(intoGroupItem);
var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t => var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t =>
t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId && t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId &&

View File

@ -79,7 +79,9 @@ namespace IRaCIS.Core.Infra.EFCore
//Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default); //Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
// 不建议使用使用跟踪然后save 部分字段更新,此种方式是更新所有字段 // 不建议使用使用跟踪然后save 部分字段更新,此种方式是更新所有字段
Task<bool> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); //Task<bool> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
Task<bool> SaveChangesAsync(CancellationToken cancellationToken = default); Task<bool> SaveChangesAsync(CancellationToken cancellationToken = default);
Task<bool> DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); Task<bool> DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);