|
@@ -1,7 +1,12 @@
|
|
|
using Aspose.Cells;
|
|
|
+using Aspose.Words.Tables;
|
|
|
+using Microsoft.AspNetCore.Mvc.ViewEngines;
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
+using MySqlX.XDevAPI.Relational;
|
|
|
using NetUV.Core.Handles;
|
|
|
+using NPOI.POIFS.Properties;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
+using NPOI.SS.Formula.PTG;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.Domain.AesEncryption;
|
|
|
using OASystem.Domain.Dtos.Statistics;
|
|
@@ -580,7 +585,6 @@ ORDER BY
|
|
|
是否由地接支付:{isFeeMark4} <br/>";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (!string.IsNullOrEmpty(paymentStr))
|
|
|
{
|
|
|
item.IsPay = 2;
|
|
@@ -656,8 +660,6 @@ ORDER BY
|
|
|
Order By CreateTime", _dto.DiId, _dto.isAudit ? "And (ccp.IsAuditGM = 1 OR ccp.IsAuditGM = 3)" : " ");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
groupCTGGRFeeViews = await _sqlSugar.SqlQueryable<GroupCTGGRFeeView>(CTGGRFeeSql).ToListAsync();
|
|
|
|
|
|
string CTGGRFeeStr = "";
|
|
@@ -1333,6 +1335,7 @@ ORDER BY
|
|
|
//pageId 38
|
|
|
int currUserId = _dto.UserId, pageId = _dto.PageId, diId = _dto.DiId;
|
|
|
bool isAudit = _dto.isAudit;
|
|
|
+
|
|
|
#region 参数验证
|
|
|
if (currUserId < 1) return Ok(JsonView(false, "员工Id为空"));
|
|
|
if (pageId < 1) return Ok(JsonView(false, "页面Id为空"));
|
|
@@ -1359,7 +1362,6 @@ ORDER BY
|
|
|
.Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Sex = x.Sex })
|
|
|
.ToList();
|
|
|
|
|
|
-
|
|
|
//获取模板
|
|
|
string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/团组费用统计模板.xls");
|
|
|
var designer = new WorkbookDesigner();
|
|
@@ -1367,14 +1369,370 @@ ORDER BY
|
|
|
// 获取工作簿中的工作表集合
|
|
|
var worksheets = designer.Workbook.Worksheets;
|
|
|
|
|
|
+ #region 获取sheet,定义datatable,局部变量
|
|
|
+ //酒店费用相关
|
|
|
+ var hotelFeeSheet = worksheets["酒店费用"];
|
|
|
+ var hotelFeeDt = new DataTable($"HotelFeeView");
|
|
|
+ decimal hotelCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //地接费用相关
|
|
|
+ var OPFeeSheet = worksheets["地接费用"];
|
|
|
+ var OPFeeDt = new DataTable($"OPFeeView");
|
|
|
+ var OPFeeLabel = string.Empty;
|
|
|
+ decimal OPCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //签证费用相关
|
|
|
var visaFeeSheet = worksheets["签证费用"];
|
|
|
+ var visaFeeDt = new DataTable($"VisaFeeView");
|
|
|
+ decimal visaCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //邀请费用相关
|
|
|
+ var OAFeeSheet = worksheets["邀请费用"];
|
|
|
+ var OAFeeDt = new DataTable($"OAFeeView");
|
|
|
+ decimal OACNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //机票费用相关
|
|
|
+ var airTicketFeeSheet = worksheets["机票费用"];
|
|
|
+ var airTicketFeeDt = new DataTable($"AirTicketFeeView");
|
|
|
+ decimal airTicketCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //保险费用相关
|
|
|
+ var insureFeeSheet = worksheets["保险费用"];
|
|
|
+ var insureFeeDt = new DataTable($"InsureFeeView");
|
|
|
+ decimal insureCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //其他费用相关
|
|
|
+ var otherFeeSheet = worksheets["其他费用"];
|
|
|
+ var otherFeeDt = new DataTable($"OtherFeeView");
|
|
|
+ decimal otherCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ //收款退还相关
|
|
|
+ var SKTHFeeSheet = worksheets["收款退还"];
|
|
|
+ var SKTHFeeDt = new DataTable($"SKTHFeeView");
|
|
|
+ decimal SKTHCNYTotalCost = 0.00M;
|
|
|
+
|
|
|
+ var totalAmount = 0.00M; //支出成本合计
|
|
|
+ var accountsAmount = 0.00M; //应收金额合计
|
|
|
+ var receivedAmount = 0.00M; //已收金额合计
|
|
|
+ var accountsProfit = 0.00M; //应收利润合计
|
|
|
+ var receiveProfit = 0.00M; //已收利润合计
|
|
|
+ var profitMargin = 0.00M; //利润差合计
|
|
|
+
|
|
|
+ //应收合计相关
|
|
|
+ var receivableFeeSheet = worksheets["团组收入(未收)"];
|
|
|
+ var receivableFeeDt = new DataTable($"ReceivableFeeView");
|
|
|
+
|
|
|
+ //已收合计相关
|
|
|
+ var receivedFeeSheet = worksheets["团组收入(已收)"];
|
|
|
+ var receivedFeeDt = new DataTable($"ReceivedFeeView");
|
|
|
+
|
|
|
+ //团组收入支出利润
|
|
|
+ var groupIEProfitDt = new DataTable($"IEProfitFeeView");
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 酒店费用
|
|
|
+
|
|
|
+ if (hotelFeeSheet != null)
|
|
|
+ {
|
|
|
+ string hotelFeeSql = string.Format(@"
|
|
|
+SELECT
|
|
|
+ hr.Id AS HrId,
|
|
|
+ hr.DiId AS HrDiId,
|
|
|
+ hr.City,
|
|
|
+ hr.HotelName,
|
|
|
+ hr.CheckInDate,
|
|
|
+ hr.CheckOutDate,
|
|
|
+ hr.CardPrice AS RoomPrice,
|
|
|
+ sd1.Name AS PaymentCurrency,
|
|
|
+ hr.SingleRoomPrice,
|
|
|
+ hr.SingleRoomCount,
|
|
|
+ hr.DoubleRoomPrice,
|
|
|
+ hr.DoubleRoomCount,
|
|
|
+ hr.SuiteRoomPrice,
|
|
|
+ hr.SuiteRoomCount,
|
|
|
+ hr.OtherRoomPrice,
|
|
|
+ hr.OtherRoomCount,
|
|
|
+ hr.BreakfastPrice,
|
|
|
+ sd4.Name AS BreakfastCurrency,
|
|
|
+ hr.Isoppay,
|
|
|
+ hr.GovernmentRent,
|
|
|
+ sd5.Name AS GovernmentRentCurrency,
|
|
|
+ hr.CityTax,
|
|
|
+ sd6.Name AS CityTaxCurrency,
|
|
|
+ ccp.PayMoney,
|
|
|
+ (
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ ) AS CNYPrice,
|
|
|
+ ccp.PayPercentage,
|
|
|
+ ccp.DayRate,
|
|
|
+ ccp.Payee,
|
|
|
+ ccp.OrbitalPrivateTransfer,
|
|
|
+ sd2.Name AS PayWay,
|
|
|
+ sd3.Name AS CardType,
|
|
|
+ ccp.IsPay,
|
|
|
+ u.CnName AS Applicant,
|
|
|
+ hr.Remark
|
|
|
+FROM
|
|
|
+ Grp_HotelReservations hr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
|
|
|
+ LEFT JOIN Sys_SetData sd1 ON ccp.PaymentCurrency = sd1.Id
|
|
|
+ LEFT JOIN Sys_SetData sd2 ON ccp.PayDId = sd2.Id
|
|
|
+ LEFT JOIN Sys_SetData sd3 ON ccp.CTDId = sd3.Id
|
|
|
+ LEFT JOIN Sys_Users u ON ccp.CreateUserId = u.Id
|
|
|
+ LEFT JOIN Sys_SetData sd4 ON hr.BreakfastCurrency = sd4.Id
|
|
|
+ LEFT JOIN Sys_SetData sd5 ON hr.GovernmentRentCurrency = sd5.Id
|
|
|
+ LEFT JOIN Sys_SetData sd6 ON hr.CityTaxCurrency = sd6.Id
|
|
|
+WHERE
|
|
|
+ hr.IsDel = 0
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 76 {1}
|
|
|
+ AND ccp.PayMoney <> 0
|
|
|
+ AND hr.DiId = {0}
|
|
|
+ORDER BY
|
|
|
+ CheckInDate Asc", _dto.DiId, _dto.isAudit ? "AND (ccp.IsAuditGM = 1 Or ccp.IsAuditGM = 3)" : " ");
|
|
|
+
|
|
|
+ var groupHotelFeeViews = await _sqlSugar.SqlQueryable<GroupHotelFeeView>(hotelFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ if (groupHotelFeeViews.Any())
|
|
|
+ {
|
|
|
+ var _setDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+
|
|
|
+ var hotelSubIds = groupHotelFeeViews.Select(it => it.HrId).ToList();
|
|
|
+
|
|
|
+ var groupHotelContentFeeViews = await _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => hotelSubIds.Contains(it.HrId)).ToListAsync();
|
|
|
+
|
|
|
+ var teamRateData = await _teamRateRep.PostGroupRateInfoByDiId(_dto.DiId);
|
|
|
+ foreach (var item in groupHotelFeeViews)
|
|
|
+ {
|
|
|
+ if (groupHotelContentFeeViews.Count > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ string paymentStr = string.Empty;
|
|
|
+
|
|
|
+ var roomData = groupHotelContentFeeViews.Find(it => it.HrId == item.HrId && it.PriceType == 1); //房费
|
|
|
+
|
|
|
+ item.RoomPrice = roomData?.Price ?? 0.00M;
|
|
|
+ if (item.RoomPrice != 0)
|
|
|
+ {
|
|
|
+ if (roomData.IsPay == 0) paymentStr += $"房费:未付款<br/>";
|
|
|
+
|
|
|
+ item.RoomPriceCurrency = _setDatas.Find(it => it.Id == roomData?.Currency)?.Name;
|
|
|
+ string feeMark1 = roomData?.OrbitalPrivateTransfer == 0 ? "公转" : "私转";
|
|
|
+ string isFeeMark1 = roomData?.IsOppay == 1 ? "是" : "否";
|
|
|
+ item.RoomInfoTips = @$"当时汇率:{roomData?.Rate.ToString("#0.0000")} <br/>
|
|
|
+ 收款方:{roomData?.Payee}<br/>
|
|
|
+ 费用标识:{feeMark1} <br/>
|
|
|
+ 支付方式:{_setDatas.Find(it => it.Id == roomData?.PayDId)?.Name} <br/>
|
|
|
+ 卡类型:{_setDatas.Find(it => it.Id == roomData?.CTDId)?.Name}<br/>
|
|
|
+ 是否由地接支付:{isFeeMark1} <br/>";
|
|
|
+ }
|
|
|
+
|
|
|
+ var breakfastData = groupHotelContentFeeViews.Find(it => it.HrId == item.HrId && it.PriceType == 2); //早餐
|
|
|
+
|
|
|
+ item.BreakfastPrice = breakfastData?.Price ?? 0.00M;
|
|
|
+
|
|
|
+ if (item.BreakfastPrice != 0)
|
|
|
+ {
|
|
|
+ if (breakfastData.IsPay == 0) paymentStr += $"早餐:未付款<br/>";
|
|
|
+
|
|
|
+ item.BreakfastCurrency = _setDatas.Find(it => it.Id == breakfastData?.Currency)?.Name;
|
|
|
+ string feeMark2 = breakfastData?.OrbitalPrivateTransfer == 0 ? "公转" : "私转";
|
|
|
+ string isFeeMark2 = breakfastData?.IsOppay == 1 ? "是" : "否";
|
|
|
+ item.BreakfastInfoTips = @$"当时汇率:{breakfastData?.Rate.ToString("#0.0000")} <br/>
|
|
|
+ 收款方:{breakfastData?.Payee}<br/>
|
|
|
+ 费用标识:{feeMark2} <br/>
|
|
|
+ 支付方式:{_setDatas.Find(it => it.Id == roomData?.PayDId)?.Name} <br/>
|
|
|
+ 卡类型:{_setDatas.Find(it => it.Id == roomData?.CTDId)?.Name} <br/>
|
|
|
+ 是否由地接支付:{isFeeMark2} <br/>";
|
|
|
+ }
|
|
|
+
|
|
|
+ var landTaxData = groupHotelContentFeeViews.Find(it => it.HrId == item.HrId && it.PriceType == 3); //地税
|
|
|
+
|
|
|
+ item.GovernmentRent = landTaxData?.Price ?? 0.00M;
|
|
|
+
|
|
|
+ if (item.GovernmentRent != 0)
|
|
|
+ {
|
|
|
+ if (landTaxData.IsPay == 0) paymentStr += $"地税:未付款<br/>";
|
|
|
+
|
|
|
+ item.GovernmentRentCurrency = _setDatas.Find(it => it.Id == landTaxData?.Currency)?.Name;
|
|
|
+ string feeMark3 = landTaxData?.OrbitalPrivateTransfer == 0 ? "公转" : "私转";
|
|
|
+ string isFeeMark3 = landTaxData?.IsOppay == 1 ? "是" : "否";
|
|
|
+ item.GovernmentRentTips = @$"当时汇率:{landTaxData?.Rate.ToString("#0.0000")} <br/>
|
|
|
+ 收款方:{landTaxData?.Payee}<br/>
|
|
|
+ 费用标识:{feeMark3} <br/>
|
|
|
+ 支付方式:{_setDatas.Find(it => it.Id == landTaxData?.PayDId)?.Name} <br/>
|
|
|
+ 卡类型:{_setDatas.Find(it => it.Id == landTaxData?.CTDId)?.Name} <br/>
|
|
|
+ 是否由地接支付:{isFeeMark3} <br/>";
|
|
|
+ }
|
|
|
+
|
|
|
+ var cityTaxData = groupHotelContentFeeViews.Find(it => it.HrId == item.HrId && it.PriceType == 4); //城市税
|
|
|
+
|
|
|
+ item.CityTax = cityTaxData?.Price ?? 0.00M;
|
|
|
+
|
|
|
+ if (item.CityTax != 0)
|
|
|
+ {
|
|
|
+ if (cityTaxData.IsPay == 0) paymentStr += $"城市税:未付款<br/>";
|
|
|
+ item.CityTaxCurrency = _setDatas.Find(it => it.Id == cityTaxData?.Currency)?.Name;
|
|
|
+ string feeMark4 = cityTaxData?.OrbitalPrivateTransfer == 0 ? "公转" : "私转";
|
|
|
+ string isFeeMark4 = landTaxData?.IsOppay == 1 ? "是" : "否";
|
|
|
+ item.CityTaxTips = @$"当时汇率:{cityTaxData?.Rate.ToString("#0.0000")} <br/>
|
|
|
+ 收款方:{cityTaxData?.Payee}<br/>
|
|
|
+ 费用标识:{feeMark4} <br/>
|
|
|
+ 支付方式:{_setDatas.Find(it => it.Id == cityTaxData?.PayDId)?.Name} <br/>
|
|
|
+ 卡类型:{_setDatas.Find(it => it.Id == cityTaxData?.CTDId)?.Name} <br/>
|
|
|
+ 是否由地接支付:{isFeeMark4} <br/>";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(paymentStr))
|
|
|
+ {
|
|
|
+ item.IsPay = 2;
|
|
|
+ item.PayTips = paymentStr;
|
|
|
+ }
|
|
|
+ //item.CNYPrice = roomData?.Price ?? 0.00M * roomData?.Rate ?? 0.00M +
|
|
|
+ // breakfastData?.Price ?? 0.00M * breakfastData?.Rate ?? 0.00M +
|
|
|
+ // landTaxData?.Price ?? 0.00M * landTaxData?.Rate ?? 0.00M +
|
|
|
+ // cityTaxData?.Price ?? 0.00M * cityTaxData?.Rate ?? 0.00M;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ decimal roomPrice = (item.SingleRoomCount * item.SingleRoomPrice) +
|
|
|
+ (item.DoubleRoomCount * item.DoubleRoomPrice) +
|
|
|
+ (item.SuiteRoomCount * item.SuiteRoomPrice) +
|
|
|
+ (item.OtherRoomCount * item.OtherRoomPrice);
|
|
|
+ //item.RoomPrice = item.CardPrice;
|
|
|
+ item.RoomPriceCurrency = item.PaymentCurrency;
|
|
|
+ }
|
|
|
+
|
|
|
+ item.PayMoney = item.PayMoney.ConvertToDecimal1();
|
|
|
+ item.CNYPrice = item.CNYPrice.ConvertToDecimal1();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ hotelCNYTotalCost = groupHotelFeeViews.Sum(x => x.CNYPrice);
|
|
|
+ hotelFeeDt = CommonFun.ToDataTableArray(groupHotelFeeViews);
|
|
|
+ hotelFeeDt.TableName = $"HotelFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 地接费用
|
|
|
+ if (OPFeeSheet != null)
|
|
|
+ {
|
|
|
+ string CTGGRFeeSql = string.Empty;
|
|
|
+ if (groupInfo.VisitDate > Convert.ToDateTime("2024-04-17"))
|
|
|
+ {
|
|
|
+ CTGGRFeeSql = string.Format(@"Select ctggr.Id As CTGGRId,ctggr.DiId As CTGGRDiId,ctggr.PriceName As Area,ctggrc.*,ctggrc.Price As PayMoney,
|
|
|
+ sd2.name As PaymentCurrency,ccp.PayPercentage,
|
|
|
+ (ctggrc.Price * (ccp.PayPercentage / 100)) As AmountPaid,
|
|
|
+ (ctggrc.Price - ctggrc.Price * (ccp.PayPercentage / 100)) As BalancePayment,
|
|
|
+ ccp.DayRate,(ctggrc.Price * (ccp.PayPercentage / 100) * ccp.DayRate) As CNYPrice,ccp.Payee,ccp.AuditGMDate,
|
|
|
+ ccp.OrbitalPrivateTransfer,sd1.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ctggr.CreateTime
|
|
|
+ From Grp_CarTouristGuideGroundReservations ctggr
|
|
|
+ Left Join ( Select cggrc.CTGGRId,sd1.Name As PriceName,cggrc.Price*cggrc.Count As Price,sd2.Name As PriceCurrency,
|
|
|
+ cggrc.DatePrice,cggrc.PriceContent
|
|
|
+ From Grp_CarTouristGuideGroundReservationsContent cggrc
|
|
|
+ Left Join Sys_SetData sd1 On cggrc.SId = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On cggrc.Currency = sd2.Id
|
|
|
+ Where cggrc.ISdel = 0 And cggrc.Price != 0.00
|
|
|
+ ) ctggrc On ctggr.Id = ctggrc.CTGGRId
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.IsDel = 0 And ccp.CTable = 79 And ctggr.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PayDId = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where ctggr.IsDel = 0 {1} And ctggr.DiId = {0}
|
|
|
+ Order By CreateTime", _dto.DiId, _dto.isAudit ? "And (ccp.IsAuditGM = 1 OR ccp.IsAuditGM = 3)" : " ");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CTGGRFeeSql = string.Format(@"Select ctggr.Id As CTGGRId,ctggr.DiId As CTGGRDiId,ctggr.PriceName As Area,
|
|
|
+ ccp.PayMoney,sd2.name As PaymentCurrency,ccp.PayPercentage,
|
|
|
+ (ccp.PayMoney * (ccp.PayPercentage / 100)) As AmountPaid,
|
|
|
+ (ccp.PayMoney -ccp.PayMoney * (ccp.PayPercentage / 100)) As BalancePayment,
|
|
|
+ ccp.DayRate,(ccp.PayMoney * (ccp.PayPercentage / 100) * ccp.DayRate) As CNYPrice,
|
|
|
+ ccp.Payee,ccp.AuditGMDate,
|
|
|
+ ccp.OrbitalPrivateTransfer,sd1.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ctggr.CreateTime
|
|
|
+ From Grp_CarTouristGuideGroundReservations ctggr
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.IsDel = 0 And ccp.CTable = 79 And ctggr.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PayDId = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where ctggr.IsDel = 0 {1} And ctggr.DiId = {0}
|
|
|
+ Order By CreateTime", _dto.DiId, _dto.isAudit ? "And (ccp.IsAuditGM = 1 OR ccp.IsAuditGM = 3)" : " ");
|
|
|
+ }
|
|
|
+
|
|
|
+ var groupOPFeeViews = await _sqlSugar.SqlQueryable<GroupCTGGRFeeView>(CTGGRFeeSql).ToListAsync();
|
|
|
+ string CTGGRFeeStr = "";
|
|
|
+ var OPToDataTableViews = groupOPFeeViews;
|
|
|
+
|
|
|
+ decimal CTGGRCNYTotalPrice = 0.00M;
|
|
|
+
|
|
|
+ //按1 地区,2 币种,3 汇率 分组计算
|
|
|
+ var groupCTGGRFeeDatas = groupOPFeeViews.GroupBy(it => it.Area);
|
|
|
+
|
|
|
+ foreach (var ctggfr in groupCTGGRFeeDatas)
|
|
|
+ {
|
|
|
+ var ctggfr_curr = ctggfr.GroupBy(it => it.PaymentCurrency);
|
|
|
+
|
|
|
+ if (ctggfr_curr.Count() > 0)
|
|
|
+ {
|
|
|
+ foreach (var curr in ctggfr_curr)
|
|
|
+ {
|
|
|
+
|
|
|
+ var ctggfr_rate = curr.GroupBy(it => it.DayRate);
|
|
|
+
|
|
|
+ if (ctggfr_rate.Count() > 0)
|
|
|
+ {
|
|
|
+ foreach (var rate in ctggfr_rate)
|
|
|
+ {
|
|
|
+ CTGGRFeeStr += string.Format($"{ctggfr.Key} 总费用:{rate.Sum(it => it.AmountPaid).ToString("#0.00")} {rate.FirstOrDefault()?.PaymentCurrency}(人民币:{rate.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00"))).ToString("#0.00")} CNY 当时支付汇率:{rate.FirstOrDefault()?.DayRate.ToString("#0.0000")})\n");
|
|
|
+ CTGGRCNYTotalPrice += rate.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CTGGRFeeStr += string.Format($"{ctggfr.Key} 总费用:{curr.Sum(it => it.AmountPaid).ToString("#0.00")} {curr.FirstOrDefault()?.PaymentCurrency}(人民币:{curr.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00"))).ToString("#0.00")} CNY 当时支付汇率:{curr.FirstOrDefault()?.DayRate.ToString("#0.0000")})\n");
|
|
|
+ CTGGRCNYTotalPrice += curr.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CTGGRFeeStr += string.Format($"{ctggfr.Key} 总费用:{ctggfr.Sum(it => it.AmountPaid).ToString("#0.00")} {ctggfr.FirstOrDefault()?.PaymentCurrency}(人民币:{ctggfr.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00"))).ToString("#0.00")} CNY 当时支付汇率:{ctggfr.FirstOrDefault()?.DayRate.ToString("#0.0000")})\n");
|
|
|
+ CTGGRCNYTotalPrice += ctggfr.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in groupOPFeeViews)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(item.AuditGMDate))
|
|
|
+ {
|
|
|
+ item.AuditGMDate = Convert.ToDateTime(item.AuditGMDate).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.DatePrice != null)
|
|
|
+ {
|
|
|
+ item.PriceName = $"{item.PriceName}({Convert.ToDateTime(item.DatePrice).ToString("yyyy-MM-dd")})";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ OPCNYTotalCost = CTGGRCNYTotalPrice;
|
|
|
+ OPFeeDt = CommonFun.ToDataTableArray(OPToDataTableViews);
|
|
|
+ OPFeeLabel = CTGGRFeeStr;
|
|
|
+ OPFeeDt.TableName = $"OPFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region 签证费用
|
|
|
if (visaFeeSheet != null)
|
|
|
{
|
|
|
string groupVisaFeeSql = string.Format(@"Select vi.Id As VisaId,vi.DIId As VisaDiId,vi.VisaClient,ccp.PayMoney,sd1.Name As PayMoneyCurrency,
|
|
|
- ccp.DayRate,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
|
|
|
- sd3.Name As CardTypeName,ccp.IsPay,u.CnName As Applicant,vi.CreateTime,
|
|
|
- (((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice
|
|
|
+ ccp.DayRate,ccp.Payee,ccp.AuditGMDate,sd2.Name As PaymentModes,sd3.Name As CardTypeName,u.CnName As Applicant,vi.CreateTime,
|
|
|
+ (((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice,ccp.ConsumptionDate,
|
|
|
+ Case When ccp.OrbitalPrivateTransfer = 0 Then '公转' Else '私转' End As CostMark,
|
|
|
+ Case When ccp.IsPay = 0 Then '未付款' Else '已付款' End As IsPay,vi.Remark
|
|
|
From Grp_VisaInfo vi
|
|
|
Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 80 And vi.Id = ccp.CId
|
|
|
Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
|
|
@@ -1383,40 +1741,458 @@ ORDER BY
|
|
|
Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
Where vi.IsDel = 0 {1} And vi.DIId = {0} Order By CreateTime", diId,isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
|
|
|
- var groupVisaFeeViews = _sqlSugar.Queryable<Grp_VisaInfo>()
|
|
|
- .InnerJoin<Grp_CreditCardPayment>((vi, ccp) => ccp.IsDel == 0 && ccp.CTable == 80 && vi.Id == ccp.CId)
|
|
|
- .LeftJoin<Sys_SetData>((vi, ccp,sd1) => ccp.PaymentCurrency == sd1.Id)
|
|
|
- .LeftJoin<Sys_SetData>((vi, ccp, sd1, sd2) => ccp.PayDId == sd2.Id)
|
|
|
- .Where((vi, ccp, sd1) => vi.IsDel == 0 && vi.DIId == diId)
|
|
|
- .WhereIF(isAudit, (vi, ccp, sd1, sd2) => ccp.IsAuditGM == 1)
|
|
|
- .Select((vi, ccp, sd1, sd2) => new {
|
|
|
- //VisaClient = GetVisaClientNames( vi.VisaClient,_clientDatas),
|
|
|
- vi.VisaClient,
|
|
|
- ccp.PayMoney,
|
|
|
- ccp.DayRate,
|
|
|
- Currency = sd1.Name,
|
|
|
- ccp.ConsumptionDate,
|
|
|
- vi.Remark,
|
|
|
- ccp.Payee,
|
|
|
- PaymentModes = sd2.Name,
|
|
|
- CostMark = ccp.OrbitalPrivateTransfer == 0 ? "公转" : "私转",
|
|
|
- PaymentStatus = ccp.IsPay == 0 ? "未付款" :"已付款"
|
|
|
- })
|
|
|
- .ToList();
|
|
|
-
|
|
|
- var visaCNYTotalCost = groupVisaFeeViews.Sum(x => x.PayMoney * x.DayRate);
|
|
|
+ var groupVisaFeeViews = _sqlSugar.SqlQueryable<GroupVisaFeeExcelView>(groupVisaFeeSql).ToList();
|
|
|
+
|
|
|
+ foreach (var item in groupVisaFeeViews)
|
|
|
+ {
|
|
|
+ string names = string.Empty;
|
|
|
+ string visaClients = item.VisaClient;
|
|
|
+ if (!string.IsNullOrEmpty(visaClients))
|
|
|
+ {
|
|
|
+ var clientIds = new string[] { };
|
|
|
+ if (visaClients.Contains(',')) clientIds = visaClients.Split(',');
|
|
|
+ else clientIds = new string[] { visaClients };
|
|
|
+
|
|
|
+ if (clientIds.Length > 0)
|
|
|
+ {
|
|
|
+ var clientIds1 = new List<int>() { };
|
|
|
+ foreach (var clientIdStr in clientIds)
|
|
|
+ {
|
|
|
+ var isInt = int.TryParse(clientIdStr, out int id);
|
|
|
+ if (isInt) clientIds1.Add(id);
|
|
|
+ }
|
|
|
+ if (clientIds1.Count > 0)
|
|
|
+ {
|
|
|
+ var clients = _clientDatas.Where(it => clientIds1.Contains(it.Id)).ToList();
|
|
|
+
|
|
|
+ foreach (var client in clients)
|
|
|
+ {
|
|
|
+ EncryptionProcessor.DecryptProperties(client);
|
|
|
+ names += $"{client.LastName + client.FirstName},";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else names = visaClients;
|
|
|
+ }
|
|
|
+ if (names.Length > 0) names = names.Substring(0, names.Length - 1);
|
|
|
+ item.VisaClient = names;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- var visaFeeDt = CommonFun.ToDataTableArray(groupVisaFeeViews);
|
|
|
+ visaCNYTotalCost = groupVisaFeeViews.Sum(x => x.CNYPrice);
|
|
|
+ visaFeeDt = CommonFun.ToDataTableArray(groupVisaFeeViews);
|
|
|
visaFeeDt.TableName = $"VisaFeeView";
|
|
|
- designer.SetDataSource(visaFeeDt);
|
|
|
- designer.SetDataSource("VisaCNYTotalCost", visaCNYTotalCost.ToString("#0.00"));
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 邀请费用
|
|
|
+
|
|
|
+ if (OAFeeSheet != null)
|
|
|
+ {
|
|
|
+ string feeSql = string.Format(@"Select ioa.Id As IOAId,ioa.DiId As IOADiId,ioa.InviterArea,ioa.Inviter,CONVERT(DATE, ioa.InviteTime) AS InviteTime,
|
|
|
+ ioa.InviteCost,sd3.Name As InviteCurrency,ioa.SendCost,sd4.Name As SendCurrency,ioa.EventsCost,
|
|
|
+ sd5.Name As EventsCurrency,ioa.TranslateCost,sd6.Name As TranslateCurrency,ccp.PayMoney,
|
|
|
+ sd7.Name As PaymentCurrency,ccp.RMBPrice As CNYPrice,ccp.ConsumptionDate,
|
|
|
+ Case When ccp.OrbitalPrivateTransfer = 0 Then '公转' Else '私转' End As CostMark,
|
|
|
+ Case When ccp.IsPay = 0 Then '未付款' Else '已付款' End As IsPay,sd2.Name As PaymentModes,
|
|
|
+ ccp.Payee,ioa.Remark,ccp.AuditGMDate,u.CnName As Applicant,ioa.CreateTime
|
|
|
+ From Grp_InvitationOfficialActivities ioa
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 81 And ioa.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
|
|
|
+ Left Join Sys_SetData sd3 On ioa.InviteCurrency = sd3.Id
|
|
|
+ Left Join Sys_SetData sd4 On ioa.SendCurrency = sd4.Id
|
|
|
+ Left Join Sys_SetData sd5 On ioa.EventsCurrency = sd5.Id
|
|
|
+ Left Join Sys_SetData sd6 On ioa.TranslateCurrency = sd6.Id
|
|
|
+ Left Join Sys_SetData sd7 On ccp.PaymentCurrency = sd7.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where ioa.IsDel = 0 {1} And ioa.Diid = {0} Order By CreateTime", diId, isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+
|
|
|
+ var feeViews = _sqlSugar.SqlQueryable<GroupOAFeeExcelView>(feeSql).ToList();
|
|
|
+
|
|
|
+ OACNYTotalCost = feeViews.Sum(x => x.CNYPrice);
|
|
|
+ OAFeeDt = CommonFun.ToDataTableArray(feeViews);
|
|
|
+ OAFeeDt.TableName = $"OAFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 机票费用
|
|
|
+
|
|
|
+ if (airTicketFeeSheet != null)
|
|
|
+ {
|
|
|
+ string feeSql = string.Format(@"Select atr.Id As AirId,atr.DIId As AirDiId,atr.FlightsCode,atr.FlightsCity,
|
|
|
+ sd4.Name As AirTypeName,atr.FlightsDate,atr.FlightsTime,atr.ClientName,atr.ClientNum,
|
|
|
+ atr.PriceDescription,ccp.PayMoney,ccp.DayRate,sd1.Name As PayMoneyCurrency,
|
|
|
+ (((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice,ccp.ConsumptionDate,
|
|
|
+ ccp.Payee,Case When ccp.OrbitalPrivateTransfer = 0 Then '公转' Else '私转' End As CostMark,
|
|
|
+ Case When ccp.IsPay = 0 Then '未付款' Else '已付款' End As IsPay,sd2.Name As PaymentModes,
|
|
|
+ sd3.Name As CardType,ccp.AuditGMDate,u.CnName As Applicant,atr.CreateTime,atr.Remark
|
|
|
+ From Grp_AirTicketReservations atr
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 85 And atr.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
|
|
|
+ Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
|
|
|
+ Left Join Sys_SetData sd4 On atr.CType = sd4.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where atr.IsDel = 0 {1} And atr.DiId = {0} Order By CreateTime", diId, isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+
|
|
|
+ var feeViews = _sqlSugar.SqlQueryable<GroupAirTicketExcelView>(feeSql).ToList();
|
|
|
+
|
|
|
+ airTicketCNYTotalCost = feeViews.Sum(x => x.CNYPrice);
|
|
|
+ airTicketFeeDt = CommonFun.ToDataTableArray(feeViews);
|
|
|
+ airTicketFeeDt.TableName = $"AirTicketFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 保险费用
|
|
|
+
|
|
|
+ if (insureFeeSheet != null)
|
|
|
+ {
|
|
|
+ string feeSql = string.Format(@"Select ic.Id As InsuranceId,ic.Diid As InsuranceDiId,ClientName,ccp.PayMoney,
|
|
|
+ sd1.Name As PayMoneyCurrency,ccp.DayRate,ccp.PayMoney * ccp.DayRate As CNYPrice,ccp.ConsumptionDate,
|
|
|
+ Case When ccp.OrbitalPrivateTransfer = 0 Then '公转' Else '私转' End As CostMark,
|
|
|
+ Case When ccp.IsPay = 0 Then '未付款' Else '已付款' End As IsPay,sd2.Name As PaymentModes,
|
|
|
+ ccp.Payee,ccp.AuditGMDate,u.CnName As Applicant,ic.CreateTime,ic.Remark
|
|
|
+ From Grp_Customers ic
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 82 And ic.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where ic.IsDel = 0 {1} And ic.DiId = {0} Order By CreateTime", diId, isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+
|
|
|
+ var feeViews = _sqlSugar.SqlQueryable<GroupInsureExcelView>(feeSql).ToList();
|
|
|
+
|
|
|
+ foreach (var item in feeViews)
|
|
|
+ {
|
|
|
+ string itemClientName = "";
|
|
|
+ string insClients = item.ClientName;
|
|
|
+ if (!string.IsNullOrEmpty(insClients))
|
|
|
+ {
|
|
|
+ string[] clientIds = new string[] { };
|
|
|
+ if (insClients.Contains(',')) clientIds = insClients.Split(',');
|
|
|
+ else clientIds = new string[] { insClients };
|
|
|
+
|
|
|
+ if (clientIds.Length > 0)
|
|
|
+ {
|
|
|
+ List<int> output = new List<int>();
|
|
|
+ foreach (var clientId in clientIds)
|
|
|
+ if (int.TryParse(clientId, out int id))
|
|
|
+ output.Add(id);
|
|
|
+
|
|
|
+ if (output.Count > 0)
|
|
|
+ {
|
|
|
+ var clients = _clientDatas.Where(it => output.Contains(it.Id)).ToList();
|
|
|
+
|
|
|
+ foreach (var client in clients)
|
|
|
+ {
|
|
|
+ EncryptionProcessor.DecryptProperties(client);
|
|
|
+ itemClientName += $"{client.LastName + client.FirstName},";
|
|
|
+ }
|
|
|
+ if (itemClientName.Length > 0)
|
|
|
+ {
|
|
|
+ itemClientName = itemClientName.Substring(0, itemClientName.Length - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else itemClientName = insClients;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ClientName = itemClientName;
|
|
|
+ }
|
|
|
+
|
|
|
+ insureCNYTotalCost = feeViews.Sum(x => x.CNYPrice);
|
|
|
+ insureFeeDt = CommonFun.ToDataTableArray(feeViews);
|
|
|
+ insureFeeDt.TableName = $"InsureFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 其他费用
|
|
|
+
|
|
|
+ if (insureFeeSheet != null)
|
|
|
+ {
|
|
|
+ string feeSql = string.Format(@"Select dp.Id As DPId,dp.DiId As DPDiId,dp.PriceName,ccp.PayMoney,sd1.Name As PayMoneyCurrency,
|
|
|
+ ccp.DayRate,(((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice,ccp.ConsumptionDate,
|
|
|
+ Case When ccp.OrbitalPrivateTransfer = 0 Then '公转' Else '私转' End As CostMark,
|
|
|
+ Case When ccp.IsPay = 0 Then '未付款' Else '已付款' End As IsPay,sd2.Name As PaymentModes,
|
|
|
+ ccp.Payee,ccp.AuditGMDate,u.CnName As Applicant,dp.CreateTime,dp.Remark
|
|
|
+ From Grp_DecreasePayments dp
|
|
|
+ Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 98 And dp.Id = ccp.CId
|
|
|
+ Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where dp.IsDel = 0 And ccp.Ctable = 98 {1} And dp.Diid = {0}
|
|
|
+ Order By CreateTime", diId, isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+
|
|
|
+ var feeViews = _sqlSugar.SqlQueryable<GroupOtherFeeExcelView>(feeSql).ToList();
|
|
|
+
|
|
|
+ otherCNYTotalCost = feeViews.Sum(x => x.CNYPrice);
|
|
|
+ otherFeeDt = CommonFun.ToDataTableArray(feeViews);
|
|
|
+ otherFeeDt.TableName = $"OtherFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 收款退还
|
|
|
+
|
|
|
+ if (SKTHFeeSheet != null)
|
|
|
+ {
|
|
|
+ //删除了 And prom.PriceType = 1
|
|
|
+ string _ropSql = string.Format(@"Select u.CnName As Appliction,prom.Id As PrId,prom.DiId As PrDiId,prom.Price As PrPrice,
|
|
|
+ prom.PriceName AS PrPriceName,prom.CurrencyId As PrCurrencyId,
|
|
|
+ prom.PayType As PrPayType,prom.PriceType As PrPriceType,
|
|
|
+ ccp.RMBPrice * ccp.DayRate As RMBPrice,ccp.*,prom.CreateTime As PrCreateTime,prom.Remark AS SKTHRemark
|
|
|
+ From Fin_PaymentRefundAndOtherMoney prom
|
|
|
+ Left Join Grp_CreditCardPayment ccp On prom.DiId = ccp.DIId And prom.Id = ccp.CId
|
|
|
+ Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
+ Where prom.IsDel = 0
|
|
|
+ And prom.PayType = 1
|
|
|
+ And ccp.CTable = 285
|
|
|
+ {1}
|
|
|
+ And prom.DiId = {0} Order By PrCreateTime", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+ var _promDatas = await _sqlSugar.SqlQueryable<Gsd_PaymentRefundAndOtherMoneyDataSource1View>(_ropSql).ToListAsync();
|
|
|
+
|
|
|
+ if (_promDatas.Any())
|
|
|
+ {
|
|
|
+ var _promView = new List<Gsd_PaymentRefundAndOtherMoneyView>();
|
|
|
+ var _setDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+
|
|
|
+ foreach (var ropItem in _promDatas)
|
|
|
+ {
|
|
|
+ string thisCueencyCode = "Unknown";
|
|
|
+ string thisCueencyName = "Unknown";
|
|
|
+ var currency = _setDatas.Where(it => it.Id == ropItem.PaymentCurrency).FirstOrDefault();
|
|
|
+ if (currency != null)
|
|
|
+ {
|
|
|
+ thisCueencyCode = currency.Name;
|
|
|
+ thisCueencyName = currency.Remark;
|
|
|
+ }
|
|
|
+
|
|
|
+ string orbitalPrivateTransferStr = "Unknown";
|
|
|
+ var orbitalPrivateTransfer = _setDatas.Where(it => it.Id == ropItem.OrbitalPrivateTransfer).FirstOrDefault();
|
|
|
+ if (orbitalPrivateTransfer != null)
|
|
|
+ {
|
|
|
+ orbitalPrivateTransferStr = orbitalPrivateTransfer.Name;
|
|
|
+ }
|
|
|
+
|
|
|
+ string payStr = "Unknown";
|
|
|
+ var pay = _setDatas.Where(it => it.Id == ropItem.PayDId).FirstOrDefault();
|
|
|
+ if (pay != null)
|
|
|
+ {
|
|
|
+ payStr = pay.Name;
|
|
|
+ }
|
|
|
+
|
|
|
+ var gsd_PaymentRefund = new Gsd_PaymentRefundAndOtherMoneyView()
|
|
|
+ {
|
|
|
+ Id = ropItem.Id,
|
|
|
+ DiId = ropItem.DIId,
|
|
|
+ PriceName = ropItem.PrPriceName,
|
|
|
+ PayCurrencyCode = thisCueencyCode,
|
|
|
+ PayCurrencyName = thisCueencyName,
|
|
|
+ Price = ropItem.PrPrice,
|
|
|
+ CNYPrice = ropItem.PayMoney * ropItem.DayRate,
|
|
|
+ ThisRate = ropItem.DayRate,
|
|
|
+ Payee = ropItem.Payee,
|
|
|
+ PayTime = ropItem.AuditGMDate,
|
|
|
+ OrbitalPrivateTransfer = ropItem.OrbitalPrivateTransfer,
|
|
|
+ PayType = payStr,
|
|
|
+ IsPay = ropItem.IsPay,
|
|
|
+ Applicant = ropItem.Appliction,
|
|
|
+ Remark = ropItem.SKTHRemark
|
|
|
+ };
|
|
|
+
|
|
|
+ _promView.Add(gsd_PaymentRefund);
|
|
|
+ }
|
|
|
+
|
|
|
+ SKTHCNYTotalCost = _promView.Sum(x => x.CNYPrice);
|
|
|
+ SKTHFeeDt = CommonFun.ToDataTableArray(_promView);
|
|
|
+ SKTHFeeDt.TableName = $"SKTHFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 应收金额(增加方式=实际报价时 费用必须审核才能进入团组报表)
|
|
|
+ decimal frTotalAmount = 0.00M;//应收总金额
|
|
|
+ string _frSql = string.Format(@" Select fr.Id,fr.AddingWay,fr.Status,u.CnName As Auditor,fr.AuditTime,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
|
|
|
+ sd.Name As CurrencyCode,sd.Remark As CurrencyName,fr.Rate,fr.ItemSumPrice,fr.CreateTime,fr.Remark
|
|
|
+ From Fin_ForeignReceivables fr
|
|
|
+ Left Join Sys_SetData sd On fr.Currency = sd.Id
|
|
|
+ Left Join Sys_Users u On fr.Auditor = u.Id
|
|
|
+ Where fr.IsDel = 0 And fr.Diid = {0} Order By CreateTime", _dto.DiId);
|
|
|
+ var _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
|
|
|
+
|
|
|
+ _frViews.ForEach(x =>
|
|
|
+ {
|
|
|
+ string namePrefix = string.Empty;
|
|
|
+ if (x.AddingWay == 0) namePrefix = $"账单模块-";
|
|
|
+ else if (x.AddingWay == 1) namePrefix = $"成本预算模块-";
|
|
|
+ else if (x.AddingWay == 2) namePrefix = $"实际报价-";
|
|
|
+ x.PriceName = $"{namePrefix}{x.PriceName}";
|
|
|
+ });
|
|
|
+
|
|
|
+ if (_frViews.Any())
|
|
|
+ {
|
|
|
+ accountsAmount = _frViews.Sum(it => it.ItemSumPrice);
|
|
|
+ receivableFeeDt = CommonFun.ToDataTableArray(_frViews);
|
|
|
+ receivableFeeDt.TableName = $"ReceivedFeeView";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 已收金额
|
|
|
+ decimal prTotalAmount = 0.00M;//已收总金额
|
|
|
+ string _prSql = string.Format(@"Select pr.Id,pr.Diid,pr.SectionTime As SectionTimeDt,pr.Price,pr.Currency,
|
|
|
+ sd1.Name As CurrencyCode,sd1.Remark As CurrencyName,pr.Client,
|
|
|
+ pr.ReceivablesType,sd2.Name As ReceivablesTypeName,pr.Remark,pr.CreateTime
|
|
|
+ From Fin_ProceedsReceived pr
|
|
|
+ Left Join Sys_SetData sd1 On pr.Currency = sd1.Id
|
|
|
+ Left Join Sys_SetData sd2 On pr.ReceivablesType = sd2.Id
|
|
|
+ Where pr.IsDel = 0 and pr.Diid = {0} Order By CreateTime", _dto.DiId);
|
|
|
+ var _prViews = await _sqlSugar.SqlQueryable<Gsd_ProceedsReceivedView>(_prSql).ToListAsync();
|
|
|
+
|
|
|
+ if (_prViews.Any())
|
|
|
+ {
|
|
|
+ receivedAmount = _prViews.Sum(it => it.Price);
|
|
|
+ receivedFeeDt = CommonFun.ToDataTableArray(_prViews);
|
|
|
+ receivedFeeDt.TableName = $"ReceivableFeeView";
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
+ #region 团组收入支出利润
|
|
|
+ groupIEProfitDt.Columns.AddRange(new DataColumn[] {
|
|
|
+ new DataColumn(){ ColumnName = "ModuleName"},
|
|
|
+ new DataColumn(){ ColumnName = "FeeTotal",DataType = typeof(decimal)},
|
|
|
+ new DataColumn(){ ColumnName = "FeeCurrency"},
|
|
|
+ });
|
|
|
+
|
|
|
+ var groupIEProfitDt_rows = new[] {
|
|
|
+ new object[] { $"签证费用", visaCNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"酒店费用", hotelCNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"地接费用", OPCNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"商邀费用", OACNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"机票费用", airTicketCNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"保险费用", insureCNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"其他费用", otherCNYTotalCost, $"CNY" },
|
|
|
+ new object[] { $"收款退还费用", SKTHCNYTotalCost, $"CNY" },
|
|
|
+ };
|
|
|
+
|
|
|
+ // 批量添加
|
|
|
+ foreach (var rowData in groupIEProfitDt_rows)
|
|
|
+ {
|
|
|
+ groupIEProfitDt.Rows.Add(rowData);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 统一填充数据源
|
|
|
designer.SetDataSource("GroupNo", groupNo);
|
|
|
designer.SetDataSource("GroupName", groupName);
|
|
|
designer.SetDataSource("Lister", lister);
|
|
|
+
|
|
|
+ //酒店
|
|
|
+ designer.SetDataSource(hotelFeeDt);
|
|
|
+ designer.SetDataSource("HotelCNYTotalCost", $"{hotelCNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //地接
|
|
|
+ designer.SetDataSource(OPFeeDt);
|
|
|
+ designer.SetDataSource("OPFeeLabel", OPFeeLabel);
|
|
|
+ designer.SetDataSource("OPCNYTotalCost", $"{OPCNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //签证
|
|
|
+ designer.SetDataSource(visaFeeDt);
|
|
|
+ designer.SetDataSource("VisaCNYTotalCost", $"{visaCNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //商邀
|
|
|
+ designer.SetDataSource(OAFeeDt);
|
|
|
+ designer.SetDataSource("OACNYTotalCost", $"{OACNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //机票
|
|
|
+ designer.SetDataSource(airTicketFeeDt);
|
|
|
+ designer.SetDataSource("AirTicketCNYTotalCost", $"{airTicketCNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //保险
|
|
|
+ designer.SetDataSource(insureFeeDt);
|
|
|
+ designer.SetDataSource("InsureCNYTotalCost", $"{insureCNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //其他费用
|
|
|
+ designer.SetDataSource(otherFeeDt);
|
|
|
+ designer.SetDataSource("OtherCNYTotalCost", $"{otherCNYTotalCost.ToString("#0.00")} CNY");
|
|
|
+
|
|
|
+ //收款退还
|
|
|
+ designer.SetDataSource(SKTHFeeDt);
|
|
|
+ designer.SetDataSource("SKTHCNYTotalCost", $"{SKTHCNYTotalCost.ToString("#0.00")}");
|
|
|
+
|
|
|
+ //已收金额
|
|
|
+ designer.SetDataSource(receivedFeeDt);
|
|
|
+ designer.SetDataSource("ReceivedAmount", $"{receivedAmount.ToString("#0.00")}");
|
|
|
+
|
|
|
+ //应收金额
|
|
|
+ designer.SetDataSource(receivableFeeDt);
|
|
|
+ designer.SetDataSource("AccountsAmount", $"{accountsAmount.ToString("#0.00")}");
|
|
|
+
|
|
|
+ //应收已收 -- 尾款
|
|
|
+ var balancePayment = accountsAmount - SKTHCNYTotalCost - receivedAmount;
|
|
|
+ designer.SetDataSource("BalancePayment", $"{balancePayment.ToString("#0.00")}");
|
|
|
+
|
|
|
+ //团组收入支出利润
|
|
|
+ designer.SetDataSource(groupIEProfitDt);
|
|
|
+ #region 各项费用计算
|
|
|
+ /*
|
|
|
+ * 团组报表计算方式
|
|
|
+ * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
|
|
|
+ * 应收金额 = 应收表.Sum() - 收款退还
|
|
|
+ * 已收金额 = 已收表.Sum() - 收款退还
|
|
|
+ * 应收利润(应收-支出) = 应收金额 - 当前总支出
|
|
|
+ * 已收利润(已收-支出) = 已收金额 - 当前总支出
|
|
|
+ * 利润差 = 应收利润 - 已收利润
|
|
|
+ */
|
|
|
+
|
|
|
+ totalAmount = visaCNYTotalCost + hotelCNYTotalCost + OPCNYTotalCost + OACNYTotalCost + airTicketCNYTotalCost + insureCNYTotalCost + otherCNYTotalCost;//合计金额
|
|
|
+ accountsProfit = accountsAmount - totalAmount - SKTHCNYTotalCost; //应收利润
|
|
|
+ receiveProfit = receivedAmount - totalAmount - SKTHCNYTotalCost; //已收利润
|
|
|
+ profitMargin = accountsProfit - receiveProfit; //利润差
|
|
|
+
|
|
|
+ designer.SetDataSource("TotalAmount", $"{totalAmount.ToString("#0.00")}");
|
|
|
+ designer.SetDataSource("AccountsProfit", $"{accountsProfit.ToString("#0.00")}");
|
|
|
+ designer.SetDataSource("ReceiveProfit", $"{receiveProfit.ToString("#0.00")}");
|
|
|
+ designer.SetDataSource("ProfitMargin", $"{profitMargin.ToString("#0.00")}");
|
|
|
+ #endregion
|
|
|
+
|
|
|
designer.Process();
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 单元格样式设置 未付款设置为红色
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 设置单元格样式
|
|
|
+ */
|
|
|
+ //背景颜色
|
|
|
+ Style style = designer.Workbook.CreateStyle();
|
|
|
+ style.ForegroundColor = Color.FromArgb(254, 242, 203);
|
|
|
+ style.Pattern = BackgroundType.Solid;
|
|
|
+ //字体
|
|
|
+ style.Font.Name = "微软雅黑"; // 字体名称
|
|
|
+ style.Font.Size = 10; // 字体大小
|
|
|
+ style.Font.Color = System.Drawing.Color.Black; // 字体颜色
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ StatementExportExcelSetCell(designer, hotelFeeSheet, hotelFeeDt, style, "IsPayLable", 8, "A", "V"); //酒店
|
|
|
+ StatementExportExcelSetCell(designer, OPFeeSheet, OPFeeDt, style, "IsPayLabel", 6, "A", "M"); //OP
|
|
|
+ StatementExportExcelSetCell(designer, visaFeeSheet, visaFeeDt, style, "IsPay", 6, "A", "I"); //签证
|
|
|
+ StatementExportExcelSetCell(designer, OAFeeSheet, OAFeeDt, style, "IsPay", 6, "A", "R"); //商邀
|
|
|
+ StatementExportExcelSetCell(designer, airTicketFeeSheet, airTicketFeeDt, style, "IsPay", 6, "A", "M"); //机票
|
|
|
+ StatementExportExcelSetCell(designer, insureFeeSheet, insureFeeDt, style, "IsPay", 6, "A", "I"); //保险
|
|
|
+ StatementExportExcelSetCell(designer, otherFeeSheet, otherFeeDt, style, "IsPay", 6, "A", "J"); //其他
|
|
|
+ StatementExportExcelSetCell(designer, SKTHFeeSheet, SKTHFeeDt, style, "IsPayLable", 6, "A", "K"); //首款退还
|
|
|
+ #endregion
|
|
|
+
|
|
|
//文件名
|
|
|
string fileName = $"{groupName}[{groupNo}]_团组费用清单{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
|
|
|
designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "GroupStatement/" + fileName);
|
|
@@ -1424,42 +2200,29 @@ ORDER BY
|
|
|
return Ok(JsonView(true, "成功", url));
|
|
|
}
|
|
|
|
|
|
- private string GetVisaClientNames(string nameStr, List<Crm_DeleClient> _clientDatas)
|
|
|
- {
|
|
|
- string names = string.Empty;
|
|
|
|
|
|
- string visaClients = nameStr;
|
|
|
- if (!string.IsNullOrEmpty(visaClients))
|
|
|
+ private void StatementExportExcelSetCell(WorkbookDesigner designer, Worksheet sheet,DataTable dt, Style style,string judgeLable, int startIndex, string startRange,string endRange)
|
|
|
+ {
|
|
|
+ if (designer == null) return;
|
|
|
+ if (sheet == null) return;
|
|
|
+ if (style == null) return;
|
|
|
+ if (dt == null) return;
|
|
|
+ if (string.IsNullOrEmpty(startRange)) return;
|
|
|
+ if (string.IsNullOrEmpty(endRange)) return;
|
|
|
+
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
- var clientIds = new string[] { };
|
|
|
- if (visaClients.Contains(',')) clientIds = visaClients.Split(',');
|
|
|
- else clientIds = new string[] { visaClients };
|
|
|
+ var isPayStr = dt.Rows[i][$"{judgeLable}"].ToString();
|
|
|
+ if (string.IsNullOrEmpty(isPayStr)) continue;
|
|
|
|
|
|
- if (clientIds.Length > 0)
|
|
|
+ if (isPayStr.Contains("未付款"))
|
|
|
{
|
|
|
- var clientIds1 = new List<int>() { };
|
|
|
- foreach (var clientIdStr in clientIds)
|
|
|
- {
|
|
|
- var isInt = int.TryParse(clientIdStr, out int id);
|
|
|
- if (isInt) clientIds1.Add(id);
|
|
|
- }
|
|
|
- if (clientIds1.Count > 0)
|
|
|
- {
|
|
|
- var clients = _clientDatas.Where(it => clientIds1.Contains(it.Id)).ToList();
|
|
|
-
|
|
|
- foreach (var client in clients)
|
|
|
- {
|
|
|
- EncryptionProcessor.DecryptProperties(client);
|
|
|
- names += $"{client.LastName + client.FirstName},";
|
|
|
- }
|
|
|
- }
|
|
|
- else names = visaClients;
|
|
|
+ var excelIndex = startIndex + i;
|
|
|
+ Aspose.Cells.Range range = sheet.Cells.CreateRange($"{startRange}{excelIndex}", $"{endRange}{excelIndex}");
|
|
|
+ range.ApplyStyle(style, new StyleFlag() { CellShading = true, Font = true });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (names.Length > 0) names = names.Substring(0, names.Length - 1);
|
|
|
-
|
|
|
- return names;
|
|
|
}
|
|
|
|
|
|
#endregion
|