diff --git a/IRaCIS.Core.API/Controllers/Financial/FinancialController.cs b/IRaCIS.Core.API/Controllers/Financial/FinancialController.cs
index e53dc35..276f9bc 100644
--- a/IRaCIS.Core.API/Controllers/Financial/FinancialController.cs
+++ b/IRaCIS.Core.API/Controllers/Financial/FinancialController.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using IRaCIS.Application.Interfaces;
using IRaCIS.Application.ViewModels;
using IRaCIS.Application.ViewModels.Pay;
@@ -89,6 +90,30 @@ namespace IRaCIS.Api.Controllers
return ResponseOutput.Ok(_paymentService.GetLaborPaymentList(paymentIds));
}
+ ///
+ /// 修改支付方式
+ ///
+ ///
+ ///
+ [HttpPost, Route("ChangePaymentMethod")]
+ public IResponseOutput ChangePaymentMethod(ChangePaymentMethodInDto inDto)
+ {
+ _paymentService.ChangePaymentMethod(inDto);
+
+ return ResponseOutput.Ok(true);
+ }
+
+ [HttpPost, Route("ExportLaborPayment")]
+
+ public FileResult ExportLaborPayment(List 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;
+
+ }
///
diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj
index 6bbe318..5d0e15f 100644
--- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj
+++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj
@@ -68,6 +68,7 @@
+
diff --git a/IRaCIS.Core.API/Payroll.zip b/IRaCIS.Core.API/Payroll.zip
new file mode 100644
index 0000000..f0c1e1b
Binary files /dev/null and b/IRaCIS.Core.API/Payroll.zip differ
diff --git a/IRaCIS.Core.API/Zip/Payroll.zip b/IRaCIS.Core.API/Zip/Payroll.zip
new file mode 100644
index 0000000..c89d3bf
Binary files /dev/null and b/IRaCIS.Core.API/Zip/Payroll.zip differ
diff --git a/IRaCIS.Core.API/Zip/text.txt b/IRaCIS.Core.API/Zip/text.txt
new file mode 100644
index 0000000..e69de29
diff --git a/IRaCIS.Core.API/wwwroot/Template/Payroll Summary_(云支付).xlsx b/IRaCIS.Core.API/wwwroot/Template/Payroll Summary_(云支付).xlsx
new file mode 100644
index 0000000..2e2a364
Binary files /dev/null and b/IRaCIS.Core.API/wwwroot/Template/Payroll Summary_(云支付).xlsx differ
diff --git a/IRaCIS.Core.API/wwwroot/Template/Payroll Summary_(报酬).xlsx b/IRaCIS.Core.API/wwwroot/Template/Payroll Summary_(报酬).xlsx
new file mode 100644
index 0000000..f14cd66
Binary files /dev/null and b/IRaCIS.Core.API/wwwroot/Template/Payroll Summary_(报酬).xlsx differ
diff --git a/IRaCIS.Core.API/wwwroot/Template/paystub(云支付).xlsx b/IRaCIS.Core.API/wwwroot/Template/paystub(云支付).xlsx
new file mode 100644
index 0000000..849361c
Binary files /dev/null and b/IRaCIS.Core.API/wwwroot/Template/paystub(云支付).xlsx differ
diff --git a/IRaCIS.Core.API/wwwroot/Template/paystub(报酬).xlsx b/IRaCIS.Core.API/wwwroot/Template/paystub(报酬).xlsx
new file mode 100644
index 0000000..8a051a8
Binary files /dev/null and b/IRaCIS.Core.API/wwwroot/Template/paystub(报酬).xlsx differ
diff --git a/IRaCIS.Core.Application.Contracts/Financial/DTO/PaymentViewModel.cs b/IRaCIS.Core.Application.Contracts/Financial/DTO/PaymentViewModel.cs
index 63b4534..7633b5e 100644
--- a/IRaCIS.Core.Application.Contracts/Financial/DTO/PaymentViewModel.cs
+++ b/IRaCIS.Core.Application.Contracts/Financial/DTO/PaymentViewModel.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
+using IRaCIS.Core.Domain.Models;
namespace IRaCIS.Application.ViewModels
{
@@ -82,7 +84,113 @@ namespace IRaCIS.Application.ViewModels
// public DateTime YearMonth { get; set; }
//}
+ public class RemunerationInfo
+ {
+ public string YearMonth { get; set; }
+ public List 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 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
+ {
+ ///
+ /// 平台费
+ ///
+ public decimal PlatformFee { get; set; }
+
+ ///
+ /// 平台总额
+ ///
+ public decimal PlatformFeeSum { get {
+ return PlatformFee + ActuallyPaidCNY;
+ } }
+ }
public class TrialAnalysisDTO
{
public Guid TrialId { get; set; }
@@ -131,6 +239,8 @@ namespace IRaCIS.Application.ViewModels
public decimal TaxCNY { get; set; }
public decimal ActuallyPaidCNY { get; set; }
public decimal BankTransferCNY { get; set; }
+
+ public PaymentMethod PaymentMethod { get; set; }
}
public class ReviewerAnalysisDTO
{
diff --git a/IRaCIS.Core.Application.Contracts/Financial/IPaymentService.cs b/IRaCIS.Core.Application.Contracts/Financial/IPaymentService.cs
index 3a975b8..5258f30 100644
--- a/IRaCIS.Core.Application.Contracts/Financial/IPaymentService.cs
+++ b/IRaCIS.Core.Application.Contracts/Financial/IPaymentService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using IRaCIS.Application.ViewModels;
using IRaCIS.Application.ViewModels.Pay;
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
@@ -24,6 +25,10 @@ namespace IRaCIS.Application.Interfaces
List GetReviewerAnalysisList(AnalysisQueryDTO param);
+ Stream ExportLaborPayment(List paymentIds);
+
+ void ChangePaymentMethod(ChangePaymentMethodInDto inDto);
+
}
diff --git a/IRaCIS.Core.Application/Financial/FinancialService.cs b/IRaCIS.Core.Application/Financial/FinancialService.cs
index d4d0ff2..ff99e90 100644
--- a/IRaCIS.Core.Application/Financial/FinancialService.cs
+++ b/IRaCIS.Core.Application/Financial/FinancialService.cs
@@ -13,6 +13,10 @@ using System.Linq;
using System.Linq.Expressions;
using IRaCIS.Core.Domain.Interfaces;
using IRaCIS.Core.Domain.Models;
+using System.IO;
+using MiniExcelLibs;
+using Microsoft.AspNetCore.Http;
+using System.IO.Compression;
namespace IRaCIS.Application.Services
{
@@ -33,6 +37,7 @@ namespace IRaCIS.Application.Services
private readonly IMapper _mapper;
+
public FinancialService(IPaymentRepository costStatisticsRepository,
IReviewerPayInfoRepository doctorPayInfoRepository,
ITrialRepository trialRepository,
@@ -1192,9 +1197,127 @@ namespace IRaCIS.Application.Services
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 paymentIds)
+ {
+ List 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(),
+ };
+
+ CloudPaymentInfo cloudPaymentInfo = new CloudPaymentInfo()
+ {
+
+ YearMonth = remunerationList.Select(x => x.YearMonth).FirstOrDefault(),
+ Rows = new List(),
+ };
+
+ 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 GetLaborPaymentList(List 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 payInfo in _doctorPayInfoRepository.GetAll() on payment.DoctorId equals payInfo.DoctorId
select new LaborPayment()
@@ -1208,7 +1331,8 @@ namespace IRaCIS.Application.Services
YearMonth = payment.YearMonth,
Phone = reviewer.Phone,
AccountNumber = payInfo.BankCardNumber,
- Bank = payInfo.BankName
+ Bank = payInfo.BankName,
+ PaymentMethod=payment.PaymentMethod
//TaxCNY = payment.TaxCNY,
//ActuallyPaidCNY = payment.ActuallyPaidCNY,
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj
index 12c2f17..d001820 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj
@@ -37,6 +37,7 @@
+
diff --git a/IRaCIS.Core.Domain.Share/DoctorStatus.cs b/IRaCIS.Core.Domain.Share/DoctorStatus.cs
index 6c89c7a..7b7a0fb 100644
--- a/IRaCIS.Core.Domain.Share/DoctorStatus.cs
+++ b/IRaCIS.Core.Domain.Share/DoctorStatus.cs
@@ -14,6 +14,7 @@
ConfirmRefuse = 2
}
+
public enum ReviewerEnrollStatus
{
diff --git a/IRaCIS.Core.Domain/Financial/Payment.cs b/IRaCIS.Core.Domain/Financial/Payment.cs
index c56e419..ceb5d3d 100644
--- a/IRaCIS.Core.Domain/Financial/Payment.cs
+++ b/IRaCIS.Core.Domain/Financial/Payment.cs
@@ -15,6 +15,8 @@ namespace IRaCIS.Core.Domain.Models
public decimal PaymentUSD { get; set; }
public decimal PaymentCNY { get; set; }
public decimal ExchangeRate { get; set; }
+
+ public PaymentMethod PaymentMethod { get; set; }
public decimal AdjustmentCNY { get; set; }
public decimal AdjustmentUSD { get; set; }
@@ -36,4 +38,17 @@ namespace IRaCIS.Core.Domain.Models
public Guid CreateUserId { get; set; }
public DateTime CreateTime { get; set; }
}
+
+ public enum PaymentMethod
+ {
+ ///
+ ///
+ ///
+ Remuneration = 0,
+
+ ///
+ /// ֧
+ ///
+ CloudPayment = 1
+ }
}