修改仓储
parent
9b419aafe0
commit
dc968efd1b
|
@ -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;
|
||||
|
||||
|
@ -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,11 +120,17 @@ 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.UpdateAsync(payment);
|
||||
|
||||
await _paymentRepository.SaveChangesAsync();
|
||||
}
|
||||
|
@ -177,8 +190,6 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
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 });
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<ReviewerPayInformation>(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();
|
||||
|
|
|
@ -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<TrialPaymentPrice>(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<TrialPaymentPrice>(trialSowPath));
|
||||
await _trialExtRepository.InsertFromDTOAsync(trialSowPath);
|
||||
}
|
||||
else//更新
|
||||
{
|
||||
await _trialExtRepository.UpdateAsync(_mapper.Map(trialSowPath, trialPaymentPrice));
|
||||
await _trialExtRepository.UpdateFromDTOAsync(trialSowPath);
|
||||
}
|
||||
|
||||
var success = await _trialExtRepository.SaveChangesAsync();
|
||||
|
|
|
@ -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 变更为有价格了
|
||||
|
||||
|
|
|
@ -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<Attachment>(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();
|
||||
|
|
|
@ -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<Enroll>(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 &&
|
||||
|
|
|
@ -79,7 +79,9 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
//Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
|
||||
// 不建议使用,使用跟踪,然后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> DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
|
||||
|
||||
|
|
Loading…
Reference in New Issue