|
@@ -3268,6 +3268,7 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> StatisticsYOY(YOYDto _dto)
|
|
|
{
|
|
|
+
|
|
|
if (_dto.Year < 1) return Ok(JsonView(false,"操作失败"));
|
|
|
|
|
|
|
|
@@ -3423,37 +3424,37 @@ SELECT
|
|
|
(
|
|
|
SELECT
|
|
|
CAST(
|
|
|
- SUM(
|
|
|
- ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
- ) AS DECIMAL(12, 2)
|
|
|
+ SUM((gec.PriceSum * gec.Coefficient * ccp.DayRate)) AS DECIMAL(12, 2)
|
|
|
)
|
|
|
FROM
|
|
|
- Grp_HotelReservations hr
|
|
|
- INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
|
|
|
+ OA2023DB.dbo.Fin_GroupExtraCost gec
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON gec.Id = ccp.CId
|
|
|
WHERE
|
|
|
- hr.IsDel = 0
|
|
|
- AND ccp.IsDel = 0
|
|
|
- AND ccp.CTable = 76
|
|
|
+ ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 1015
|
|
|
AND ccp.IsAuditGM = 1
|
|
|
- AND ccp.PayMoney <> 0
|
|
|
- AND ccp.IsPay = 0
|
|
|
- AND di.Id = hr.DiId
|
|
|
- ) AS HotelAmount,
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND di.Id = gec.DiId
|
|
|
+ ) AS ExcessAmount,
|
|
|
(
|
|
|
SELECT
|
|
|
CAST(
|
|
|
- SUM((gec.PriceSum * gec.Coefficient * ccp.DayRate)) AS DECIMAL(12, 2)
|
|
|
+ SUM(
|
|
|
+ ((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100
|
|
|
+ ) AS DECIMAL(12, 2)
|
|
|
)
|
|
|
FROM
|
|
|
- OA2023DB.dbo.Fin_GroupExtraCost gec
|
|
|
- INNER JOIN Grp_CreditCardPayment ccp ON gec.Id = ccp.CId
|
|
|
+ Fin_PaymentRefundAndOtherMoney prom
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON prom.DiId = ccp.DIId
|
|
|
+ AND prom.Id = ccp.CId
|
|
|
WHERE
|
|
|
- ccp.IsDel = 0
|
|
|
- AND ccp.CTable = 1015
|
|
|
+ prom.IsDel = 0
|
|
|
+ AND prom.PayType = 1
|
|
|
+ AND ccp.CTable = 285
|
|
|
AND ccp.IsAuditGM = 1
|
|
|
AND ccp.IsPay = 1
|
|
|
- AND di.Id = gec.DiId
|
|
|
- ) AS ExcessAmount
|
|
|
+ AND di.Id = prom.DiId
|
|
|
+ ) AS SKTHAmount
|
|
|
FROM
|
|
|
Grp_DelegationInfo di
|
|
|
WHERE
|
|
@@ -3462,29 +3463,63 @@ WHERE
|
|
|
AND di.VisitDate BETWEEN '{0}' AND '{1}'
|
|
|
ORDER BY
|
|
|
di.VisitDate
|
|
|
-",beginDt,endDt);
|
|
|
+", beginDt,endDt);
|
|
|
|
|
|
var data = await _sqlSugar.SqlQueryable<StatisticsYOYView>(sql).ToListAsync();
|
|
|
|
|
|
var thisYearData = data.Where(x => x.Year == _dto.Year).ToList();
|
|
|
var lastYearData = data.Where(x => x.Year == (_dto.Year - 1)).ToList();
|
|
|
|
|
|
- List<YOYReturnView> SalesYOYData = new List<YOYReturnView>();
|
|
|
+ List<YOYReturnView> salesYOYData = new List<YOYReturnView>();
|
|
|
+ List<YOYReturnView> costYOYData = new List<YOYReturnView>();
|
|
|
+ List<YOYReturnView> grossProfitYOYData = new List<YOYReturnView>();
|
|
|
int monthIndex = 1;
|
|
|
while (monthIndex < 13)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ var thisMonthData = thisYearData.Where(x => x.Month == monthIndex).ToList();
|
|
|
+ var lastMonthData = lastYearData.Where(x => x.Month == monthIndex).ToList();
|
|
|
+ var thisGroupIds = thisMonthData.Select(x => x.Id).ToList();
|
|
|
+ var lastGroupIds = lastMonthData.Select(x => x.Id).ToList();
|
|
|
+
|
|
|
+ decimal thisSalesAmount = thisMonthData.Sum(x => x.SaleAmount),
|
|
|
+ lastSalesAmount = lastYearData.Sum(x => x.SaleAmount),
|
|
|
+ thisCostAmount = thisMonthData.Sum(x => x.CostAmount),
|
|
|
+ lastCostAmount = lastYearData.Sum(x => x.CostAmount),
|
|
|
+ thisgrossProfitAmount = thisMonthData.Sum(x => x.GrossProfitAmount),
|
|
|
+ lastgrossProfitAmount = lastYearData.Sum(x => x.GrossProfitAmount);
|
|
|
+
|
|
|
+ salesYOYData.Add(new YOYReturnView(_dto.Year, monthIndex, thisSalesAmount, lastSalesAmount, thisGroupIds, lastGroupIds));
|
|
|
+ costYOYData.Add(new YOYReturnView(_dto.Year, monthIndex, thisCostAmount, lastCostAmount, thisGroupIds, lastGroupIds));
|
|
|
+ grossProfitYOYData.Add(new YOYReturnView(_dto.Year, monthIndex, thisgrossProfitAmount, lastgrossProfitAmount, thisGroupIds, lastGroupIds));
|
|
|
|
|
|
monthIndex++;
|
|
|
}
|
|
|
+ salesYOYData = salesYOYData.OrderBy(x => x.Month).ToList();
|
|
|
+ costYOYData = costYOYData.OrderBy(x => x.Month).ToList();
|
|
|
+ grossProfitYOYData = grossProfitYOYData.OrderBy(x => x.Month).ToList();
|
|
|
|
|
|
|
|
|
+ return Ok(JsonView(true,"操作成功!", new { salesYOYData = salesYOYData, costYOYData = costYOYData, grossProfitYOYData = grossProfitYOYData }));
|
|
|
+ }
|
|
|
|
|
|
- return Ok(JsonView(true,"操作成功!", new { data = data, SalesData = new { },CostData = new { } }));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static decimal CalculateYOY(decimal currentAmount, decimal contemporaneousAmount)
|
|
|
+ {
|
|
|
+ decimal rate = 0.00M;
|
|
|
+ if (contemporaneousAmount != 0)
|
|
|
+ {
|
|
|
+ rate = (currentAmount - contemporaneousAmount) / contemporaneousAmount;
|
|
|
+ }
|
|
|
+
|
|
|
+ return rate;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|