|
@@ -1103,19 +1103,417 @@ namespace OASystem.API.Controllers
|
|
|
//企业利润-团组利润
|
|
|
//企业利润-会务利润
|
|
|
|
|
|
- ///// <summary>
|
|
|
- ///// 计算企业利润 - 已收利润
|
|
|
- ///// </summary>
|
|
|
- ///// <param name="tIds"></param>
|
|
|
- ///// <param name="year"></param>
|
|
|
- ///// <returns></returns>
|
|
|
- //private async Task<object> CorporateProfitAsync(List<int> tIds, string year)
|
|
|
- //{
|
|
|
- // if (tIds.Count < 1)
|
|
|
- // {
|
|
|
- // return null;
|
|
|
- // }
|
|
|
- //}
|
|
|
+ /// <summary>
|
|
|
+ /// 团组报表
|
|
|
+ /// Details
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">团组列表请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("PostCorporateProfit")]
|
|
|
+ //[JsonConverter(typeof(DecimalConverter), 2)]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostCorporateProfit(PostCorporateProfitDto _dto)
|
|
|
+ {
|
|
|
+ /*
|
|
|
+ * 团组报表计算方式
|
|
|
+ * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
|
|
|
+ * 应收金额 = 应收表.Sum()
|
|
|
+ * 已收金额 = 已收表.Sum()
|
|
|
+ * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
|
|
|
+ * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
+ #region 参数验证
|
|
|
+ if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
|
|
|
+ if (_dto.PageId < 1) _dto.PageId = 38; //团组报表页面Id
|
|
|
+ if (_dto.BusinessType > 3 && _dto.BusinessType < 1) return Ok(JsonView(false, "请输入有效的BusinessType参数,1 所有 2 团组 3 会务"));
|
|
|
+ if (_dto.StatisticsType > 2 && _dto.StatisticsType < 1) return Ok(JsonView(false, "请输入有效的StatisticsType参数,1 月份 2 季度"));
|
|
|
+
|
|
|
+ PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
+ #region 页面操作权限验证
|
|
|
+ pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
|
|
|
+
|
|
|
+ if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.Year}-01-01 00:00:00";
|
|
|
+ string endDt = $"{_dto.Year}-12-31 59:59:59";
|
|
|
+
|
|
|
+
|
|
|
+ List<int> diIds = new List<int>();
|
|
|
+
|
|
|
+
|
|
|
+ return Ok(JsonView(true));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="diIds"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task< List<CorporateProfit>> CorporateProfit1(List<int> diIds)
|
|
|
+ {
|
|
|
+ List < CorporateProfit > corporateProfits = new List<CorporateProfit>();
|
|
|
+ string diIdStr = string.Join(",", diIds);
|
|
|
+ if (diIds.Count < 1)
|
|
|
+ {
|
|
|
+ return corporateProfits;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 计算团组利润
|
|
|
+
|
|
|
+ #region 费用类型 币种,转账,客户信息
|
|
|
+
|
|
|
+ List<Sys_SetData> _setDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+ var _clientDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ foreach (var _diId in diIds)
|
|
|
+ {
|
|
|
+
|
|
|
+ List<ExpenditureInfo> expenditureInfos = new List<ExpenditureInfo>();
|
|
|
+
|
|
|
+
|
|
|
+ #region 团组收入
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 应收报表
|
|
|
+ */
|
|
|
+ decimal frTotalAmount = 0.00M;//应收总金额
|
|
|
+ string _frSql = string.Format(@"Select fr.Id,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
|
|
|
+ From Fin_ForeignReceivables fr
|
|
|
+ Left Join Sys_SetData sd On fr.Currency = sd.Id
|
|
|
+ Where fr.IsDel = 0 And fr.Diid = {0} Order By CreateTime", _diId);
|
|
|
+ List<Gsd_ForeignReceivablesView> _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
|
|
|
+ frTotalAmount = _frViews.Sum(it => it.ItemSumPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "应收项", Amount = frTotalAmount });
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 已收报表
|
|
|
+ */
|
|
|
+ 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", _diId);
|
|
|
+ List<Gsd_ProceedsReceivedView> _prViews = await _sqlSugar.SqlQueryable<Gsd_ProceedsReceivedView>(_prSql).ToListAsync();
|
|
|
+ prTotalAmount = _prViews.Sum(it => it.Price);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "已收项", Amount = prTotalAmount });
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 超支费用
|
|
|
+ */
|
|
|
+ decimal exTotalAmount = 0.00M;
|
|
|
+ string _ecSql = string.Format(@"Select gec.Id As GECId,gec.DiId As GECDiId,gec.PriceName,ccp.PayMoney,sd1.Name As PaymentCurrency,
|
|
|
+ ccp.RMBPrice As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
|
|
|
+ sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant,gec.CreateTime
|
|
|
+ From OA2023DB.dbo.Fin_GroupExtraCost gec
|
|
|
+ Left Join Grp_CreditCardPayment ccp On gec.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
|
|
|
+ Where ccp.IsDel = 0 And ccp.CTable = 1015 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ccp.DiId = {0} Order By CreateTime", _diId);
|
|
|
+
|
|
|
+ List<Gsd_ExtraCostsView> _ExtraCostsViews = await _sqlSugar.SqlQueryable<Gsd_ExtraCostsView>(_ecSql).ToListAsync();
|
|
|
+ exTotalAmount = _ExtraCostsViews.Sum(it => it.CNYPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "超支费用", Amount = exTotalAmount });
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 收款退还
|
|
|
+ */
|
|
|
+ decimal promTotalAmount = 0.00M;// 收款退还总金额
|
|
|
+ List<Gsd_PaymentRefundAndOtherMoneyView> _promView = new List<Gsd_PaymentRefundAndOtherMoneyView>();
|
|
|
+
|
|
|
+ //删除了 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.*,prom.CreateTime As PrCreateTime
|
|
|
+ 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
|
|
|
+ And ccp.IsAuditGM = 1 And ccp.IsPay = 1
|
|
|
+ And prom.DiId = {0} Order By PrCreateTime", _diId);
|
|
|
+ var _promDatas = await _sqlSugar.SqlQueryable<Gsd_PaymentRefundAndOtherMoneyDataSource1View>(_ropSql).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;
|
|
|
+ }
|
|
|
+
|
|
|
+ Gsd_PaymentRefundAndOtherMoneyView gsd_PaymentRefund = new Gsd_PaymentRefundAndOtherMoneyView()
|
|
|
+ {
|
|
|
+ Id = ropItem.Id,
|
|
|
+ DiId = ropItem.DIId,
|
|
|
+ PriceName = ropItem.PrPriceName,
|
|
|
+ PayCurrencyCode = thisCueencyCode,
|
|
|
+ PayCurrencyName = thisCueencyName,
|
|
|
+ Price = ropItem.PrPrice,
|
|
|
+ CNYPrice = ropItem.RMBPrice,
|
|
|
+ ThisRate = ropItem.DayRate,
|
|
|
+ Payee = ropItem.Payee,
|
|
|
+ PayTime = ropItem.AuditGMDate,
|
|
|
+ OrbitalPrivateTransfer = ropItem.OrbitalPrivateTransfer,
|
|
|
+ PayType = payStr,
|
|
|
+ IsPay = ropItem.IsPay,
|
|
|
+ Applicant = ropItem.Appliction
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ _promView.Add(gsd_PaymentRefund);
|
|
|
+ }
|
|
|
+
|
|
|
+ promTotalAmount = _promView.Sum(it => it.CNYPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "收款退还", Amount = promTotalAmount });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 团组支出
|
|
|
+ GroupExpenditureView _geView = new GroupExpenditureView();
|
|
|
+
|
|
|
+ #region 酒店预定费用
|
|
|
+ List<GroupHotelFeeView> groupHotelFeeViews = new List<GroupHotelFeeView>();
|
|
|
+
|
|
|
+ string hotelFeeSql = string.Format(@"Select hr.Id As HrId,hr.DiId As HrDiId,hr.City,hr.HotelName,hr.CheckInDate,hr.CheckOutDate,
|
|
|
+ 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.RMBPrice As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,
|
|
|
+ sd2.Name As PayWay,sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant
|
|
|
+ From Grp_HotelReservations hr
|
|
|
+ Left 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 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And hr.DiId = {0}
|
|
|
+ Order By CheckInDate Asc", _diId);
|
|
|
+
|
|
|
+ groupHotelFeeViews = await _sqlSugar.SqlQueryable<GroupHotelFeeView>(hotelFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal HotelCNYTotalPrice = groupHotelFeeViews.Sum(it => it.CNYPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "酒店预定", Amount = HotelCNYTotalPrice });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 地接费用
|
|
|
+
|
|
|
+ List<GroupCTGGRFeeView> groupCTGGRFeeViews = new List<GroupCTGGRFeeView>();
|
|
|
+
|
|
|
+ string CTGGRFeeSql = string.Format(@"Select ctggr.Id As CTGGRId,ctggr.DiId As CTGGRDiId,ctggr.Area,ctggrc.*,ctggrc.Price As PayMoney,
|
|
|
+ sd2.name As PaymentCurrency,ccp.PayPercentage,
|
|
|
+ (ctggrc.Price / (ccp.PayPercentage / 100)) As AmountPaid,
|
|
|
+ (ctggrc.Price / (ccp.PayPercentage / 100) - ctggrc.Price) As BalancePayment,
|
|
|
+ ccp.DayRate,(ctggrc.Price * 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,sd2.Name As PriceCurrency,
|
|
|
+ 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 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ctggr.DiId = {0}
|
|
|
+ Order By CreateTime", _diId);
|
|
|
+
|
|
|
+ groupCTGGRFeeViews = await _sqlSugar.SqlQueryable<GroupCTGGRFeeView>(CTGGRFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal CTGGRCNYTotalPrice = groupCTGGRFeeViews.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "地接", Amount = CTGGRCNYTotalPrice });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 机票预订费用
|
|
|
+
|
|
|
+ List<GroupAirFeeView> groupAirFeeViews = new List<GroupAirFeeView>();
|
|
|
+ string groupAirFeeSql = 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,ccp.PayMoney,
|
|
|
+ sd1.Name As PayMoneyCurrency,ccp.RMBPrice As CNYPrice,ccp.DayRate,ccp.Payee,ccp.AuditGMDate,
|
|
|
+ ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant,atr.CreateTime
|
|
|
+ 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 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And atr.DiId = {0} Order By CreateTime", _diId);
|
|
|
+ groupAirFeeViews = await _sqlSugar.SqlQueryable<GroupAirFeeView>(groupAirFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal AirCNYTotalPrice = groupAirFeeViews.Sum(it => it.CNYPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "机票预订", Amount = AirCNYTotalPrice });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 签证费用
|
|
|
+
|
|
|
+ List<GroupVisaFeeView> groupVisaFeeViews = new List<GroupVisaFeeView>();
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ Where vi.IsDel = 0 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And vi.DIId = {0} Order By CreateTime", _diId);
|
|
|
+
|
|
|
+ groupVisaFeeViews = await _sqlSugar.SqlQueryable<GroupVisaFeeView>(groupVisaFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal VisaCNYTotalPirce = groupVisaFeeViews.Sum(it => it.PayMoney);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "签证", Amount = VisaCNYTotalPirce });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 邀请/公务活动 CTable = 81
|
|
|
+
|
|
|
+ List<GroupInvitationalFeeView> groupInvitationalFeeViews = new List<GroupInvitationalFeeView>();
|
|
|
+ string groupInvitationalFeeSql = string.Format(@"Select ioa.Id As IOAId,ioa.DiId As IOADiId,ioa.InviterArea,ioa.Inviter,ioa.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.Payee,ccp.AuditGMDate,
|
|
|
+ ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,ccp.IsPay,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 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ioa.Diid = {0} Order By CreateTime", _diId);
|
|
|
+
|
|
|
+ groupInvitationalFeeViews = await _sqlSugar.SqlQueryable<GroupInvitationalFeeView>(groupInvitationalFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal InvitationalCNYTotalPrice = groupInvitationalFeeViews.Sum(it => it.CNYPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "邀请/公务活动", Amount = InvitationalCNYTotalPrice });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 保险费用
|
|
|
+ List<GroupInsuranceFeeView> groupInsuranceFeeViews = new List<GroupInsuranceFeeView>();
|
|
|
+ string groupInsuranceFeeSql = string.Format(@"Select ic.Id As InsuranceId,ic.Diid As InsuranceDiId,ClientName,ccp.PayMoney,ccp.RMBPrice As CNYPrice,
|
|
|
+ sd1.Name As PayMoneyCurrency,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,
|
|
|
+ sd2.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ic.CreateTime
|
|
|
+ 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 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ic.DiId = {0} Order By CreateTime", _diId);
|
|
|
+ groupInsuranceFeeViews = await _sqlSugar.SqlQueryable<GroupInsuranceFeeView>(groupInsuranceFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal InsuranceCNYTotalPrice = groupInsuranceFeeViews.Sum(it => it.CNYPrice);
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "保险费用", Amount = InsuranceCNYTotalPrice });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 其他款项费用 98
|
|
|
+ List<GroupDecreaseFeeView> groupDecreaseFeeViews = new List<GroupDecreaseFeeView>();
|
|
|
+ string groupDecreaseFeeSql = string.Format(@"Select dp.Id As DPId,dp.DiId As DPDiId,dp.PriceName,ccp.PayMoney,sd1.Name As PayMoneyCurrency,
|
|
|
+ (((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice,
|
|
|
+ ccp.DayRate,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,
|
|
|
+ sd2.Name As PayWay,ccp.IsPay,u.CnName As Applicant,dp.CreateTime
|
|
|
+ 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 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And dp.Diid = {0}
|
|
|
+ Order By CreateTime", _diId);
|
|
|
+ groupDecreaseFeeViews = await _sqlSugar.SqlQueryable<GroupDecreaseFeeView>(groupDecreaseFeeSql).ToListAsync();
|
|
|
+
|
|
|
+ decimal DecreaseCNYTotalPrice = groupDecreaseFeeViews.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
|
|
|
+
|
|
|
+ expenditureInfos.Add(new ExpenditureInfo() { ItemName = "其他款项", Amount = DecreaseCNYTotalPrice });
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 团组报表计算方式
|
|
|
+ * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
|
|
|
+ * 应收金额 = 应收表.Sum()
|
|
|
+ * 已收金额 = 已收表.Sum()
|
|
|
+ * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
|
|
|
+ * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
|
|
|
+ *
|
|
|
+ */
|
|
|
+ decimal _totalExpenditure = 0.00M; //总支出
|
|
|
+ decimal _amountReceivable = 0.00M; //应收金额
|
|
|
+ decimal _amountReceived = 0.00M; //已收金额
|
|
|
+ decimal _receivableProfit = 0.00M; //应收利润
|
|
|
+ decimal _receivedProfit = 0.00M; //已收利润
|
|
|
+ _totalExpenditure = HotelCNYTotalPrice + CTGGRCNYTotalPrice + AirCNYTotalPrice + VisaCNYTotalPirce + InvitationalCNYTotalPrice +
|
|
|
+ InsuranceCNYTotalPrice + DecreaseCNYTotalPrice + exTotalAmount;
|
|
|
+ _amountReceivable = frTotalAmount;
|
|
|
+ _amountReceived = prTotalAmount;
|
|
|
+ _receivableProfit = _amountReceivable - promTotalAmount - _totalExpenditure;
|
|
|
+ _receivedProfit = _amountReceived - promTotalAmount - _totalExpenditure;
|
|
|
+
|
|
|
+ corporateProfits.Add(new CorporateProfit() {
|
|
|
+ DiId = _diId,
|
|
|
+ TeamName = "",
|
|
|
+ CreateDt = "",
|
|
|
+ TotalExpenditure = _totalExpenditure,
|
|
|
+ ExpenditureItem = expenditureInfos,
|
|
|
+ AmountReceivable = _amountReceivable,
|
|
|
+ AmountReceived = _amountReceived,
|
|
|
+ ReceivableProfit = _receivableProfit,
|
|
|
+ ReceivedProfit = _receivedProfit,
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ return corporateProfits;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|