|
@@ -202,20 +202,21 @@ namespace OASystem.API.Controllers
|
|
|
* 增加方式=实际报价时 费用必须审核才能进入团组报表
|
|
|
*/
|
|
|
decimal frTotalAmount = 0.00M;//应收总金额
|
|
|
- string _frSql = string.Format(@"Select fr.Id,fr.AddingWay,fr.Status,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
|
|
|
+ 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
|
|
|
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);
|
|
|
- List<Gsd_ForeignReceivablesView> _frViews1 = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
|
|
|
+ List<Gsd_ForeignReceivablesView> _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
|
|
|
|
|
|
|
|
|
- List<Gsd_ForeignReceivablesView> _frViews = new List<Gsd_ForeignReceivablesView>();
|
|
|
- if (_frViews1.Count > 0)
|
|
|
- {
|
|
|
- _frViews.AddRange(_frViews1.Where(x => x.AddingWay != 2).ToList());
|
|
|
- _frViews.AddRange(_frViews1.Where(x => x.AddingWay == 2 && x.Status == 1).ToList());
|
|
|
- }
|
|
|
+ //List<Gsd_ForeignReceivablesView> _frViews = new List<Gsd_ForeignReceivablesView>();
|
|
|
+ //if (_frViews1.Count > 0)
|
|
|
+ //{
|
|
|
+ // _frViews.AddRange(_frViews1.Where(x => x.AddingWay != 2).ToList());
|
|
|
+ // _frViews.AddRange(_frViews1.Where(x => x.AddingWay == 2 && x.Status == 1).ToList());
|
|
|
+ //}
|
|
|
|
|
|
_frViews.ForEach(x =>
|
|
|
{
|
|
@@ -601,7 +602,7 @@ namespace OASystem.API.Controllers
|
|
|
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.DayRate) As CNYPrice,ccp.Payee,ccp.AuditGMDate,
|
|
|
+ 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,
|
|
@@ -1244,14 +1245,14 @@ namespace OASystem.API.Controllers
|
|
|
#endregion
|
|
|
|
|
|
/*
|
|
|
- * 团组报表计算方式
|
|
|
- * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
|
|
|
- * 应收金额 = 应收表.Sum()
|
|
|
- * 已收金额 = 已收表.Sum()
|
|
|
- * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
|
|
|
- * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
|
|
|
- *
|
|
|
- */
|
|
|
+ * 团组报表计算方式
|
|
|
+ * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
|
|
|
+ * 应收金额 = 应收表.Sum()
|
|
|
+ * 已收金额 = 已收表.Sum()
|
|
|
+ * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
|
|
|
+ * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
|
|
|
+ *
|
|
|
+ */
|
|
|
decimal _totalExpenditure = 0.00M; //总支出
|
|
|
decimal _amountReceivable = 0.00M; //应收金额
|
|
|
decimal _amountReceived = 0.00M; //已收金额
|
|
@@ -3270,20 +3271,16 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
if (_dto.Year < 1) return Ok(JsonView(false,"操作失败"));
|
|
|
|
|
|
|
|
|
- string thisBeginDt = $"{_dto.Year}-01-01 00:00:00",
|
|
|
- thisEndDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
-
|
|
|
- string lastBeginDt = $"{_dto.Year - 1}-01-01 00:00:00",
|
|
|
- lastEndDt = $"{_dto.Year - 1}-12-31 23:59:59";
|
|
|
-
|
|
|
- #region 营业额
|
|
|
+ string beginDt = $"{_dto.Year-1}-01-01 00:00:00",
|
|
|
+ endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
|
|
|
- string thisSql = string.Format(@"
|
|
|
+ string sql = string.Format(@"
|
|
|
SELECT
|
|
|
di.Id,
|
|
|
+ di.TeamName,
|
|
|
di.VisitDate,
|
|
|
- YEAR(di.VisitDate) AS Year,
|
|
|
- MONTH(di.VisitDate) AS Month,
|
|
|
+ YEAR(di.VisitDate) AS YEAR,
|
|
|
+ MONTH(di.VisitDate) AS MONTH,
|
|
|
(
|
|
|
SELECT
|
|
|
CAST(SUM(ItemSumPrice * Rate) AS DECIMAL(12, 2))
|
|
@@ -3293,138 +3290,199 @@ SELECT
|
|
|
IsDel = 0
|
|
|
AND AddingWay IN (0, 1, 2)
|
|
|
AND di.Id = Diid
|
|
|
- ) AS Amount
|
|
|
-FROM
|
|
|
- Grp_DelegationInfo di
|
|
|
-WHERE
|
|
|
- di.IsDel = 0
|
|
|
- AND di.IsSure = 1
|
|
|
- AND di.VisitDate BETWEEN '{0}' AND '{1}'
|
|
|
-", thisBeginDt,thisEndDt);
|
|
|
- string lastSql = string.Format(@"
|
|
|
-SELECT
|
|
|
- di.Id,
|
|
|
- di.VisitDate,
|
|
|
- YEAR(di.VisitDate) AS YEAR,
|
|
|
- MONTH(di.VisitDate) AS MONTH,
|
|
|
+ ) AS SaleAmount,
|
|
|
(
|
|
|
SELECT
|
|
|
- CAST(SUM(ItemSumPrice * Rate) AS DECIMAL(12, 2))
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ (
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ )
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
FROM
|
|
|
- Fin_ForeignReceivables
|
|
|
+ Grp_AirTicketReservations atr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 85
|
|
|
+ AND atr.Id = ccp.CId
|
|
|
WHERE
|
|
|
- IsDel = 0
|
|
|
- AND AddingWay IN (0, 1, 2)
|
|
|
- AND di.Id = Diid
|
|
|
- ) AS Amount
|
|
|
-FROM
|
|
|
- Grp_DelegationInfo di
|
|
|
-WHERE
|
|
|
- di.IsDel = 0
|
|
|
- AND di.IsSure = 1
|
|
|
- AND di.VisitDate BETWEEN '{0}' AND '{1}'
|
|
|
-", lastBeginDt, lastEndDt);
|
|
|
-
|
|
|
-
|
|
|
- var thisSalesData = _sqlSugar.SqlQueryable<SalesSqlView>(thisSql).ToList();
|
|
|
- var lastSalesData = _sqlSugar.SqlQueryable<SalesSqlView>(lastSql).ToList();
|
|
|
-
|
|
|
- List<SalesReturnView> salesData = new List<SalesReturnView>();
|
|
|
- int salesMonth = 1;
|
|
|
- while (salesMonth < 13)
|
|
|
- {
|
|
|
- var thisMonthData = thisSalesData.Where(x => x.Month == salesMonth).ToList();
|
|
|
- var lastMonthData = lastSalesData.Where(x => x.Month == salesMonth).ToList();
|
|
|
- decimal thisMonthSales = thisMonthData.Sum(x => x?.Amount ?? 0);
|
|
|
- var thisIds = thisMonthData.Select(x => x.Id).ToList();
|
|
|
- decimal lastMonthSales = lastMonthData.Sum(x => x?.Amount ?? 0);
|
|
|
- var lastIds = lastMonthData.Select(x => x.Id).ToList();
|
|
|
-
|
|
|
- salesData.Add(new SalesReturnView( _dto.Year,salesMonth, thisMonthSales, lastMonthSales, thisIds, lastIds) );
|
|
|
-
|
|
|
-
|
|
|
- salesMonth++;
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 团组成本
|
|
|
-
|
|
|
- string thisCostSql = string.Format(@"
|
|
|
-SELECT
|
|
|
- di.Id,
|
|
|
- di.VisitDate,
|
|
|
- YEAR(di.VisitDate) AS YEAR,
|
|
|
- MONTH(di.VisitDate) AS MONTH,
|
|
|
+ atr.IsDel = 0
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = atr.DiId
|
|
|
+ ) AirTicketAmount,
|
|
|
(
|
|
|
SELECT
|
|
|
- CAST(SUM(PayMoney * DayRate) AS DECIMAL(12, 2))
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ (
|
|
|
+ ctggr.ServiceQuotedPrice * (ccp.PayPercentage / 100) * ccp.DayRate
|
|
|
+ )
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
FROM
|
|
|
- Grp_CreditCardPayment
|
|
|
+ Grp_CarTouristGuideGroundReservations ctggr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 79
|
|
|
+ AND ctggr.Id = ccp.CId
|
|
|
WHERE
|
|
|
- IsDel = 0
|
|
|
- AND di.Id = Diid
|
|
|
- AND CTable IN(98, 81, 79, 85, 76, 80, 82)
|
|
|
- AND IsPay = 1
|
|
|
- ) AS Amount
|
|
|
-FROM
|
|
|
- Grp_DelegationInfo di
|
|
|
-WHERE
|
|
|
- di.IsDel = 0
|
|
|
- AND di.IsSure = 1
|
|
|
- AND di.VisitDate BETWEEN '{0}' AND '{1}'
|
|
|
-", thisBeginDt, thisEndDt);
|
|
|
- string lastCostSql = string.Format(@"
|
|
|
-SELECT
|
|
|
- di.Id,
|
|
|
- di.VisitDate,
|
|
|
- YEAR(di.VisitDate) AS YEAR,
|
|
|
- MONTH(di.VisitDate) AS MONTH,
|
|
|
+ ctggr.IsDel = 0
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = ctggr.DiId
|
|
|
+ ) AS OPAmount,
|
|
|
(
|
|
|
SELECT
|
|
|
- CAST(SUM(PayMoney * DayRate) AS DECIMAL(12, 2))
|
|
|
+ CAST(SUM((ccp.PayMoney * ccp.DayRate)) AS DECIMAL(12, 2))
|
|
|
FROM
|
|
|
- Grp_CreditCardPayment
|
|
|
+ Grp_DecreasePayments dp
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 98
|
|
|
+ AND dp.Id = ccp.CId
|
|
|
WHERE
|
|
|
- IsDel = 0
|
|
|
- AND di.Id = Diid
|
|
|
- AND CTable IN(98, 81, 79, 85, 76, 80, 82)
|
|
|
- AND IsPay = 1
|
|
|
- ) AS Amount
|
|
|
+ dp.IsDel = 0
|
|
|
+ AND ccp.Ctable = 98
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = dp.Diid
|
|
|
+ ) AS OtherCostAmount,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ (
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ )
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ Grp_VisaInfo vi
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 80
|
|
|
+ AND vi.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ vi.IsDel = 0
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = vi.DIId
|
|
|
+ ) AS VisaAmount,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ Grp_InvitationOfficialActivities ioa
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 81
|
|
|
+ AND ioa.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ ioa.IsDel = 0
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = ioa.Diid
|
|
|
+ ) AS OAAmount,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ Grp_Customers ic
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 82
|
|
|
+ AND ic.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ ic.IsDel = 0
|
|
|
+ AND ccp.IsAuditGM = 1And ccp.IsPay = 1
|
|
|
+ AND di.Id = ic.DiId
|
|
|
+ ) AS InsureAmount,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ Grp_HotelReservations hr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ hr.IsDel = 0
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 76
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.PayMoney <> 0
|
|
|
+ AND ccp.IsPay = 0
|
|
|
+ AND di.Id = hr.DiId
|
|
|
+ ) AS HotelAmount,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ SUM(
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ Grp_HotelReservations hr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ hr.IsDel = 0
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 76
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.PayMoney <> 0
|
|
|
+ AND ccp.IsPay = 0
|
|
|
+ AND di.Id = hr.DiId
|
|
|
+ ) AS HotelAmount,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ SUM((gec.PriceSum * gec.Coefficient * ccp.DayRate)) AS DECIMAL(12, 2)
|
|
|
+ )
|
|
|
+ FROM
|
|
|
+ OA2023DB.dbo.Fin_GroupExtraCost gec
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON gec.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 1015
|
|
|
+ AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = gec.DiId
|
|
|
+ ) AS ExcessAmount
|
|
|
FROM
|
|
|
Grp_DelegationInfo di
|
|
|
WHERE
|
|
|
di.IsDel = 0
|
|
|
AND di.IsSure = 1
|
|
|
AND di.VisitDate BETWEEN '{0}' AND '{1}'
|
|
|
-", lastBeginDt, lastEndDt);
|
|
|
+ORDER BY
|
|
|
+ di.VisitDate
|
|
|
+",beginDt,endDt);
|
|
|
|
|
|
+ var data = await _sqlSugar.SqlQueryable<StatisticsYOYView>(sql).ToListAsync();
|
|
|
|
|
|
- var thisCostData = _sqlSugar.SqlQueryable<SalesSqlView>(thisCostSql).ToList();
|
|
|
- var lastCostData = _sqlSugar.SqlQueryable<SalesSqlView>(lastCostSql).ToList();
|
|
|
+ var thisYearData = data.Where(x => x.Year == _dto.Year).ToList();
|
|
|
+ var lastYearData = data.Where(x => x.Year == (_dto.Year - 1)).ToList();
|
|
|
|
|
|
- List<SalesReturnView> costData = new List<SalesReturnView>();
|
|
|
- int costMonth = 1;
|
|
|
- while (costMonth < 13)
|
|
|
+ List<YOYReturnView> SalesYOYData = new List<YOYReturnView>();
|
|
|
+ int monthIndex = 1;
|
|
|
+ while (monthIndex < 13)
|
|
|
{
|
|
|
- var thisMonthData = thisSalesData.Where(x => x.Month == costMonth).ToList();
|
|
|
- var lastMonthData = lastSalesData.Where(x => x.Month == costMonth).ToList();
|
|
|
- decimal thisMonthSales = thisMonthData.Sum(x => x?.Amount ?? 0);
|
|
|
- var thisIds = thisMonthData.Select(x => x.Id).ToList();
|
|
|
- decimal lastMonthSales = lastMonthData.Sum(x => x?.Amount ?? 0);
|
|
|
- var lastIds = lastMonthData.Select(x => x.Id).ToList();
|
|
|
|
|
|
- costData.Add(new SalesReturnView(_dto.Year, costMonth, thisMonthSales, lastMonthSales, thisIds, lastIds));
|
|
|
|
|
|
|
|
|
- costMonth++;
|
|
|
- }
|
|
|
|
|
|
+ monthIndex++;
|
|
|
+ }
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
|
|
|
- return Ok(JsonView(true,"操作成功!", new { SalesData = salesData,CostData = costData }));
|
|
|
+ return Ok(JsonView(true,"操作成功!", new { data = data, SalesData = new { },CostData = new { } }));
|
|
|
}
|
|
|
|
|
|
#endregion
|