master
parent
9e9868bc4c
commit
dec70d0efd
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Application.ViewModels;
|
using IRaCIS.Application.ViewModels;
|
||||||
using IRaCIS.Application.ViewModels.Pay;
|
using IRaCIS.Application.ViewModels.Pay;
|
||||||
|
@ -89,6 +90,30 @@ namespace IRaCIS.Api.Controllers
|
||||||
return ResponseOutput.Ok(_paymentService.GetLaborPaymentList(paymentIds));
|
return ResponseOutput.Ok(_paymentService.GetLaborPaymentList(paymentIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改支付方式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost, Route("ChangePaymentMethod")]
|
||||||
|
public IResponseOutput ChangePaymentMethod(ChangePaymentMethodInDto inDto)
|
||||||
|
{
|
||||||
|
_paymentService.ChangePaymentMethod(inDto);
|
||||||
|
|
||||||
|
return ResponseOutput.Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, Route("ExportLaborPayment")]
|
||||||
|
|
||||||
|
public FileResult ExportLaborPayment(List<Guid> paymentIds)
|
||||||
|
{
|
||||||
|
|
||||||
|
Stream stream = _paymentService.ExportLaborPayment(paymentIds); ;
|
||||||
|
FileStreamResult actionresult = new FileStreamResult(stream, new Microsoft.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"));
|
||||||
|
actionresult.FileDownloadName = "Payroll.zip";
|
||||||
|
return actionresult;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
<Folder Include="Controllers\ReviewerApi\" />
|
<Folder Include="Controllers\ReviewerApi\" />
|
||||||
<Folder Include="Properties\PublishProfiles\" />
|
<Folder Include="Properties\PublishProfiles\" />
|
||||||
<Folder Include="wwwroot\UploadFile\" />
|
<Folder Include="wwwroot\UploadFile\" />
|
||||||
|
<Folder Include="wwwroot\Template\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
||||||
|
using IRaCIS.Core.Domain.Models;
|
||||||
|
|
||||||
namespace IRaCIS.Application.ViewModels
|
namespace IRaCIS.Application.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -82,7 +84,113 @@ namespace IRaCIS.Application.ViewModels
|
||||||
// public DateTime YearMonth { get; set; }
|
// public DateTime YearMonth { get; set; }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
public class RemunerationInfo
|
||||||
|
{
|
||||||
|
public string YearMonth { get; set; }
|
||||||
|
|
||||||
|
public List<Remuneration> Rows { get; set; }
|
||||||
|
|
||||||
|
public decimal SumPaymentCNY
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Rows.Sum(x => x.PaymentCNY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal SumTaxCNY
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Rows.Sum(x => x.TaxCNY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal SumActuallyPaidCNY
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Rows.Sum(x => x.ActuallyPaidCNY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ChangePaymentMethodInDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public PaymentMethod PaymentMethod { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CloudPaymentInfo
|
||||||
|
{
|
||||||
|
public string YearMonth { get; set; }
|
||||||
|
|
||||||
|
public List<CloudPayment> Rows { get; set; }
|
||||||
|
|
||||||
|
public decimal SumActuallyPaidCNY
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Rows.Sum(x => x.ActuallyPaidCNY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal SumPlatformFee
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Rows.Sum(x => x.PlatformFee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public decimal SumPlatformFeeSum
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Rows.Sum(x => x.PlatformFeeSum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Remuneration
|
||||||
|
{
|
||||||
|
public string ChineseName { get; set; }
|
||||||
|
|
||||||
|
public string ResidentId { get; set; }
|
||||||
|
|
||||||
|
public string Phone { get; set; }
|
||||||
|
|
||||||
|
public string AccountNumber { get; set; }
|
||||||
|
|
||||||
|
public string Bank { get; set; }
|
||||||
|
|
||||||
|
public decimal PaymentCNY { get; set; }
|
||||||
|
|
||||||
|
public decimal TaxCNY { get; set; }
|
||||||
|
public decimal ActuallyPaidCNY { get; set; }
|
||||||
|
|
||||||
|
public decimal BankTransferCNY { get; set; }
|
||||||
|
|
||||||
|
public string YearMonth { get; set; }
|
||||||
|
|
||||||
|
public string NextYearMonth { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CloudPayment : Remuneration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 平台费
|
||||||
|
/// </summary>
|
||||||
|
public decimal PlatformFee { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平台总额
|
||||||
|
/// </summary>
|
||||||
|
public decimal PlatformFeeSum { get {
|
||||||
|
return PlatformFee + ActuallyPaidCNY;
|
||||||
|
} }
|
||||||
|
}
|
||||||
public class TrialAnalysisDTO
|
public class TrialAnalysisDTO
|
||||||
{
|
{
|
||||||
public Guid TrialId { get; set; }
|
public Guid TrialId { get; set; }
|
||||||
|
@ -131,6 +239,8 @@ namespace IRaCIS.Application.ViewModels
|
||||||
public decimal TaxCNY { get; set; }
|
public decimal TaxCNY { get; set; }
|
||||||
public decimal ActuallyPaidCNY { get; set; }
|
public decimal ActuallyPaidCNY { get; set; }
|
||||||
public decimal BankTransferCNY { get; set; }
|
public decimal BankTransferCNY { get; set; }
|
||||||
|
|
||||||
|
public PaymentMethod PaymentMethod { get; set; }
|
||||||
}
|
}
|
||||||
public class ReviewerAnalysisDTO
|
public class ReviewerAnalysisDTO
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using IRaCIS.Application.ViewModels;
|
using IRaCIS.Application.ViewModels;
|
||||||
using IRaCIS.Application.ViewModels.Pay;
|
using IRaCIS.Application.ViewModels.Pay;
|
||||||
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
||||||
|
@ -24,6 +25,10 @@ namespace IRaCIS.Application.Interfaces
|
||||||
List<ReviewerAnalysisDTO> GetReviewerAnalysisList(AnalysisQueryDTO param);
|
List<ReviewerAnalysisDTO> GetReviewerAnalysisList(AnalysisQueryDTO param);
|
||||||
|
|
||||||
|
|
||||||
|
Stream ExportLaborPayment(List<Guid> paymentIds);
|
||||||
|
|
||||||
|
void ChangePaymentMethod(ChangePaymentMethodInDto inDto);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@ using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using IRaCIS.Core.Domain.Interfaces;
|
using IRaCIS.Core.Domain.Interfaces;
|
||||||
using IRaCIS.Core.Domain.Models;
|
using IRaCIS.Core.Domain.Models;
|
||||||
|
using System.IO;
|
||||||
|
using MiniExcelLibs;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.IO.Compression;
|
||||||
|
|
||||||
namespace IRaCIS.Application.Services
|
namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
|
@ -33,6 +37,7 @@ namespace IRaCIS.Application.Services
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public FinancialService(IPaymentRepository costStatisticsRepository,
|
public FinancialService(IPaymentRepository costStatisticsRepository,
|
||||||
IReviewerPayInfoRepository doctorPayInfoRepository,
|
IReviewerPayInfoRepository doctorPayInfoRepository,
|
||||||
ITrialRepository trialRepository,
|
ITrialRepository trialRepository,
|
||||||
|
@ -1192,9 +1197,127 @@ namespace IRaCIS.Application.Services
|
||||||
return returnList.OrderBy(t => t.ReviewerCode).ToList();
|
return returnList.OrderBy(t => t.ReviewerCode).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangePaymentMethod(ChangePaymentMethodInDto inDto)
|
||||||
|
{
|
||||||
|
var payment = _paymentRepository.FindSingleOrDefault(t => t.Id == inDto.Id);
|
||||||
|
payment.PaymentMethod = inDto.PaymentMethod;
|
||||||
|
_paymentRepository.Update(payment);
|
||||||
|
_paymentRepository.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stream ExportLaborPayment(List<Guid> paymentIds)
|
||||||
|
{
|
||||||
|
List<LaborPayment> laborPaymentList = GetLaborPaymentList(paymentIds);
|
||||||
|
|
||||||
|
//报酬
|
||||||
|
var remunerationList = laborPaymentList.Where(x => x.PaymentMethod == PaymentMethod.Remuneration).ToList();
|
||||||
|
|
||||||
|
//
|
||||||
|
var cloudPaymentList = laborPaymentList.Where(x => x.PaymentMethod == PaymentMethod.CloudPayment).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
DirectoryInfo folder = new DirectoryInfo("./file");
|
||||||
|
|
||||||
|
foreach (FileInfo file in folder.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInfo fi2 = new FileInfo("./Zip/Payroll.zip");
|
||||||
|
fi2.Delete();
|
||||||
|
|
||||||
|
RemunerationInfo remunerationInfo = new RemunerationInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
YearMonth = remunerationList.Select(x => x.YearMonth).FirstOrDefault(),
|
||||||
|
Rows = new List<Remuneration>(),
|
||||||
|
};
|
||||||
|
|
||||||
|
CloudPaymentInfo cloudPaymentInfo = new CloudPaymentInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
YearMonth = remunerationList.Select(x => x.YearMonth).FirstOrDefault(),
|
||||||
|
Rows = new List<CloudPayment>(),
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in remunerationList)
|
||||||
|
{
|
||||||
|
var remunerationSingle = new Remuneration()
|
||||||
|
{
|
||||||
|
ChineseName = item.ChineseName,
|
||||||
|
ResidentId = item.ResidentId,
|
||||||
|
YearMonth = item.YearMonth,
|
||||||
|
NextYearMonth = DateTime.Parse(item.YearMonth + "-01").AddMonths(1).ToString("yyyy-MM"),
|
||||||
|
PaymentCNY = item.PaymentCNY,
|
||||||
|
TaxCNY = item.TaxCNY,
|
||||||
|
ActuallyPaidCNY = item.ActuallyPaidCNY,
|
||||||
|
BankTransferCNY = item.BankTransferCNY,
|
||||||
|
Bank=item.Bank,
|
||||||
|
AccountNumber=item.AccountNumber,
|
||||||
|
Phone=item.Phone,
|
||||||
|
};
|
||||||
|
remunerationInfo.Rows.Add(remunerationSingle);
|
||||||
|
|
||||||
|
var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\Template\paystub(报酬).xlsx");
|
||||||
|
|
||||||
|
// 导入excel
|
||||||
|
MiniExcel.SaveAsByTemplate($"./file/{item.ChineseName}_paystub_{item.YearMonth}(报酬).xlsx", path, remunerationSingle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in cloudPaymentList)
|
||||||
|
{
|
||||||
|
var cloudPaymentSingle = new CloudPayment()
|
||||||
|
{
|
||||||
|
ChineseName= item.ChineseName,
|
||||||
|
ResidentId = item.ResidentId,
|
||||||
|
YearMonth = item.YearMonth,
|
||||||
|
NextYearMonth = DateTime.Parse(item.YearMonth + "-01").AddMonths(1).ToString("yyyy-MM"),
|
||||||
|
PaymentCNY = item.PaymentCNY,
|
||||||
|
TaxCNY = item.PaymentCNY*(decimal)0.1,
|
||||||
|
ActuallyPaidCNY = item.ActuallyPaidCNY* (decimal)0.9,
|
||||||
|
BankTransferCNY = item.BankTransferCNY * (decimal)0.9,
|
||||||
|
PlatformFee= item.ActuallyPaidCNY * (decimal)0.9*(decimal)0.065,
|
||||||
|
Bank = item.Bank,
|
||||||
|
AccountNumber = item.AccountNumber,
|
||||||
|
Phone = item.Phone,
|
||||||
|
|
||||||
|
};
|
||||||
|
cloudPaymentInfo.Rows.Add(cloudPaymentSingle);
|
||||||
|
var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\Template\paystub(云支付).xlsx");
|
||||||
|
MiniExcel.SaveAsByTemplate($"./file/{item.ChineseName}_paystub_{item.YearMonth}(云支付).xlsx", path, cloudPaymentSingle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var remunerationPath = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\Template\Payroll Summary_(报酬).xlsx");
|
||||||
|
MiniExcel.SaveAsByTemplate($"./file/Payroll Summary_{remunerationInfo.YearMonth}(报酬).xlsx", remunerationPath, remunerationInfo);
|
||||||
|
|
||||||
|
|
||||||
|
var cloudPaymentPath = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\Template\Payroll Summary_(云支付).xlsx");
|
||||||
|
MiniExcel.SaveAsByTemplate($"./file/Payroll Summary_{cloudPaymentInfo.YearMonth}(云支付).xlsx", cloudPaymentPath, cloudPaymentInfo);
|
||||||
|
|
||||||
|
ZipFile.CreateFromDirectory("./file", "Zip/Payroll.zip");
|
||||||
|
|
||||||
|
Stream stream = new System.IO.FileStream("./Zip/Payroll.zip", FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (FileInfo file in folder.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<LaborPayment> GetLaborPaymentList(List<Guid> paymentIds)
|
public List<LaborPayment> GetLaborPaymentList(List<Guid> paymentIds)
|
||||||
{
|
{
|
||||||
var query = from payment in _paymentRepository.GetAll().Where(t => paymentIds.Contains(t.Id))
|
var query =
|
||||||
|
//from payment in _paymentRepository.GetAll().Where(t => paymentIds.Contains(t.Id))
|
||||||
|
from payment in _paymentRepository.GetAll()
|
||||||
join reviewer in _doctorRepository.GetAll() on payment.DoctorId equals reviewer.Id
|
join reviewer in _doctorRepository.GetAll() on payment.DoctorId equals reviewer.Id
|
||||||
join payInfo in _doctorPayInfoRepository.GetAll() on payment.DoctorId equals payInfo.DoctorId
|
join payInfo in _doctorPayInfoRepository.GetAll() on payment.DoctorId equals payInfo.DoctorId
|
||||||
select new LaborPayment()
|
select new LaborPayment()
|
||||||
|
@ -1208,7 +1331,8 @@ namespace IRaCIS.Application.Services
|
||||||
YearMonth = payment.YearMonth,
|
YearMonth = payment.YearMonth,
|
||||||
Phone = reviewer.Phone,
|
Phone = reviewer.Phone,
|
||||||
AccountNumber = payInfo.BankCardNumber,
|
AccountNumber = payInfo.BankCardNumber,
|
||||||
Bank = payInfo.BankName
|
Bank = payInfo.BankName,
|
||||||
|
PaymentMethod=payment.PaymentMethod
|
||||||
|
|
||||||
//TaxCNY = payment.TaxCNY,
|
//TaxCNY = payment.TaxCNY,
|
||||||
//ActuallyPaidCNY = payment.ActuallyPaidCNY,
|
//ActuallyPaidCNY = payment.ActuallyPaidCNY,
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
<PackageReference Include="MailKit" Version="2.8.0" />
|
<PackageReference Include="MailKit" Version="2.8.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.7" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.7" />
|
||||||
<PackageReference Include="MimeKit" Version="2.9.1" />
|
<PackageReference Include="MimeKit" Version="2.9.1" />
|
||||||
|
<PackageReference Include="MiniExcel" Version="1.26.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.1" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.1" />
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum ReviewerEnrollStatus
|
public enum ReviewerEnrollStatus
|
||||||
{
|
{
|
||||||
Yes = 1,
|
Yes = 1,
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public decimal PaymentCNY { get; set; }
|
public decimal PaymentCNY { get; set; }
|
||||||
public decimal ExchangeRate { get; set; }
|
public decimal ExchangeRate { get; set; }
|
||||||
|
|
||||||
|
public PaymentMethod PaymentMethod { get; set; }
|
||||||
|
|
||||||
public decimal AdjustmentCNY { get; set; }
|
public decimal AdjustmentCNY { get; set; }
|
||||||
public decimal AdjustmentUSD { get; set; }
|
public decimal AdjustmentUSD { get; set; }
|
||||||
public DateTime CalculateTime { get; set; } = DateTime.Now;
|
public DateTime CalculateTime { get; set; } = DateTime.Now;
|
||||||
|
@ -36,4 +38,17 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public Guid CreateUserId { get; set; }
|
public Guid CreateUserId { get; set; }
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PaymentMethod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报酬
|
||||||
|
/// </summary>
|
||||||
|
Remuneration = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 云支付
|
||||||
|
/// </summary>
|
||||||
|
CloudPayment = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue