|
@@ -33,6 +33,7 @@ using OASystem.RedisRepository.RedisAsyncHelper;
|
|
|
using System.Data;
|
|
|
using OfficeOpenXml.Export.ToDataTable;
|
|
|
using Aspose.Cells;
|
|
|
+using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -3257,7 +3258,12 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
|
|
|
|
|
|
#region 统计模块
|
|
|
-
|
|
|
+ /*
|
|
|
+ * 1、营业额(今年和去年的)、成本支出(今年和去年的)、毛利润(今年和去年的)
|
|
|
+2、国交数据统计(1、机票票数、2、机票到达地 3、酒店预订地区TOP10排序、酒店房型地区间数、商邀邀请国家数量TOP10排序)
|
|
|
+3、会务数据统计(1、会务城市TOP10排序
|
|
|
+ *
|
|
|
+ */
|
|
|
/// <summary>
|
|
|
/// 同比
|
|
|
/// 营业额(今年和去年的)、成本支出(今年和去年的)、毛利润(今年和去年的)
|
|
@@ -3481,12 +3487,12 @@ ORDER BY
|
|
|
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);
|
|
|
+ decimal thisSalesAmount = thisMonthData.Sum(x => x?.SaleAmount ?? 0.00M),
|
|
|
+ lastSalesAmount = lastMonthData.Sum(x => x?.SaleAmount ?? 0.00M),
|
|
|
+ thisCostAmount = thisMonthData.Sum(x => x?.CostAmount ?? 0.00M),
|
|
|
+ lastCostAmount = lastMonthData.Sum(x => x?.CostAmount ?? 0.00M),
|
|
|
+ thisgrossProfitAmount = thisMonthData.Sum(x => x?.GrossProfitAmount ?? 0.00M),
|
|
|
+ lastgrossProfitAmount = lastMonthData.Sum(x => x?.GrossProfitAmount ?? 0.00M);
|
|
|
|
|
|
salesYOYData.Add(new YOYReturnView(_dto.Year, monthIndex, thisSalesAmount, lastSalesAmount, thisGroupIds, lastGroupIds));
|
|
|
costYOYData.Add(new YOYReturnView(_dto.Year, monthIndex, thisCostAmount, lastCostAmount, thisGroupIds, lastGroupIds));
|
|
@@ -3503,23 +3509,229 @@ ORDER BY
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 同比计算
|
|
|
+ /// 国交数据统计-机票相关
|
|
|
+ /// 1、机票票数、2、机票到达地
|
|
|
/// </summary>
|
|
|
- /// <param name="currentAmount">本期金额</param>
|
|
|
- /// <param name="contemporaneousAmount">同期金额</param>
|
|
|
- /// <returns>同期增长/下降率</returns>
|
|
|
- private static decimal CalculateYOY(decimal currentAmount, decimal contemporaneousAmount)
|
|
|
+ /// <param name="_dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("StatisticsAirTicket")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsAirTicket(YOYDto _dto)
|
|
|
{
|
|
|
- decimal rate = 0.00M;
|
|
|
- if (contemporaneousAmount != 0)
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
|
|
|
+
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.Year}-01-01 00:00:00",
|
|
|
+ endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
+
|
|
|
+ string sql = string.Format(@"
|
|
|
+SELECT
|
|
|
+ atr.DIId,
|
|
|
+ atr.FlightsDate,
|
|
|
+ YEAR(atr.FlightsDate) AS YEAR,
|
|
|
+ MONTH(atr.FlightsDate) AS MONTH,
|
|
|
+ atr.CType,
|
|
|
+ sd.Name As CTypeName,
|
|
|
+ atr.FlightsCity,
|
|
|
+ atr.ClientNum,
|
|
|
+ atr.ClientName
|
|
|
+FROM
|
|
|
+ Grp_AirTicketReservations atr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON atr.Id = ccp.CId
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ AND CTable = 85
|
|
|
+ Left Join Sys_SetData sd On atr.CType = sd.Id
|
|
|
+WHERE
|
|
|
+ atr.IsDel = 0
|
|
|
+ And atr.CType IN(457,458,459,460,574,575)
|
|
|
+ AND CHARINDEX('行程单',atr.ClientName) = 0
|
|
|
+ AND CHARINDEX('返点',atr.ClientName) = 0
|
|
|
+ AND CHARINDEX('-1',atr.ClientName) = 0
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ AND atr.FlightsDate BETWEEN '{0}' AND '{1}'
|
|
|
+ ORDER BY atr.FlightsDate
|
|
|
+", beginDt, endDt);
|
|
|
+
|
|
|
+ var data = await _sqlSugar.SqlQueryable<StatisticsAirTicketView>(sql).ToListAsync();
|
|
|
+
|
|
|
+ var groupIds = data.Select(x => x.DIId).ToList();
|
|
|
+ //处理城市数据
|
|
|
+ var threeCodeData = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
+ //处理团组名称
|
|
|
+ var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => groupIds.Contains(x.Id)).Select(x => new { Id = x.Id, GroupName = x.TeamName }).ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ data.ForEach(x => {
|
|
|
+ string cityName = "";
|
|
|
+ if (!string.IsNullOrEmpty(x.FlightsCity))
|
|
|
+ {
|
|
|
+ string cityCode = x.FlightsCity.Replace("-", "").Replace("/", "");
|
|
|
+
|
|
|
+ int cityNum = cityCode.Length / 3;
|
|
|
+ if (cityCode.Length % 3 == 0)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < cityNum; i++)
|
|
|
+ {
|
|
|
+ string code = "";
|
|
|
+ if (i == 0) code = cityCode.Substring(0, 3);
|
|
|
+ else code = cityCode.Substring(i * 3, 3);
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(code))
|
|
|
+ {
|
|
|
+ if (i == cityNum-1)
|
|
|
+ {
|
|
|
+ cityName += threeCodeData.Find(x => x.Three.Equals(code))?.City ?? "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string str1 = threeCodeData.Find(x => x.Three.Equals(code))?.City ?? "";
|
|
|
+ cityName += str1 + "、";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ x.FlightsCityName = cityName;
|
|
|
+ });
|
|
|
+
|
|
|
+ var airTicketNumData = new List<AirTicketReturnView>();
|
|
|
+ var airTicketAreaData = new List<AirTicketCityReturnView>();
|
|
|
+
|
|
|
+ int monthIndex = 1;
|
|
|
+ while (monthIndex < 13)
|
|
|
{
|
|
|
- rate = (currentAmount - contemporaneousAmount) / contemporaneousAmount;
|
|
|
+ var monthData = data.Where(x => x.Month == monthIndex).ToList();
|
|
|
+
|
|
|
+ //机票票数处理
|
|
|
+ int airticket_quantity = monthData.Sum(x => x.ClientNum);
|
|
|
+ var linkGroupIds = monthData.Select(x => x.DIId).ToList();
|
|
|
+ List<AitTicketInfo> aitTicketInfos = new List<AitTicketInfo>();
|
|
|
+
|
|
|
+ foreach (var item in monthData)
|
|
|
+ {
|
|
|
+ string groupName = groupNames.Find(x => item.DIId == x.Id)?.GroupName ?? "";
|
|
|
+ aitTicketInfos.Add(new AitTicketInfo(item.DIId,groupName,item.ClientNum));
|
|
|
+ }
|
|
|
+ var aitTicketInfosGroupBy = aitTicketInfos.GroupBy(x => x.Id);
|
|
|
+
|
|
|
+ List<AitTicketInfo> aitTicketInfos1 = new List<AitTicketInfo>();
|
|
|
+ foreach (var item in aitTicketInfosGroupBy)
|
|
|
+ {
|
|
|
+
|
|
|
+ aitTicketInfos1.Add(new AitTicketInfo(item.Key, item.First().GroupName, item.Sum(x => x.Quantity)));
|
|
|
+ }
|
|
|
+
|
|
|
+ aitTicketInfos1 = aitTicketInfos1.OrderBy(x => x.Quantity).ToList();
|
|
|
+
|
|
|
+
|
|
|
+ linkGroupIds = linkGroupIds.Distinct().ToList();
|
|
|
+
|
|
|
+ airTicketNumData.Add(new AirTicketReturnView(_dto.Year, monthIndex, airticket_quantity, aitTicketInfos1,linkGroupIds));
|
|
|
+
|
|
|
+ //机票城市处理
|
|
|
+ //城市处理
|
|
|
+ List<string> airTicketCityInfos = new List<string>();
|
|
|
+ foreach (var item in monthData)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(item.FlightsCityName))
|
|
|
+ {
|
|
|
+ if (item.FlightsCityName.Contains("、"))
|
|
|
+ {
|
|
|
+ var cityArray = item.FlightsCityName.Split("、").ToList();
|
|
|
+ foreach (var item1 in cityArray)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(item.FlightsCityName))
|
|
|
+ {
|
|
|
+ airTicketCityInfos.Add(item1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ airTicketCityInfos.Add(item.FlightsCityName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //int quantity1 = airTicketCityInfos.Count;
|
|
|
+ int city_totalquantity = 0;
|
|
|
+
|
|
|
+ var airTicketCityInfosGroupby = airTicketCityInfos.GroupBy(x => x);
|
|
|
+ var airTicketCityInfos1 = new List<AirTicketCityInfo>();
|
|
|
+ foreach (var item in airTicketCityInfosGroupby)
|
|
|
+ {
|
|
|
+ var city_quantity = item.ToList().Count;
|
|
|
+ city_totalquantity += city_quantity;
|
|
|
+ airTicketCityInfos1.Add(new AirTicketCityInfo(item.Key, city_quantity));
|
|
|
+ }
|
|
|
+
|
|
|
+ airTicketCityInfos1 = airTicketCityInfos1.OrderByDescending(x => x.Quantity).ToList();
|
|
|
+
|
|
|
+ airTicketAreaData.Add(new AirTicketCityReturnView(_dto.Year, monthIndex, city_totalquantity, airTicketCityInfos1, linkGroupIds));
|
|
|
+
|
|
|
+ monthIndex++;
|
|
|
}
|
|
|
|
|
|
- return rate;
|
|
|
+ return Ok(JsonView(true, "操作成功!", new { airTicketNumData = airTicketNumData, airTicketAreaData = airTicketAreaData }));
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 国交数据统计-酒店相关、商要邀请
|
|
|
+ /// 酒店预订地区TOP10排序、酒店房型地区间数、商邀邀请国家数量TOP10
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("StatisticsHotel")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsHotel()
|
|
|
+ {
|
|
|
+
|
|
|
+ string sql = string.Format(@"
|
|
|
+SELECT
|
|
|
+ hr.DIId,
|
|
|
+ hr.City,
|
|
|
+ hr.HotelName,
|
|
|
+ sd.Name AS BookinSite,
|
|
|
+ hr.CheckInDate,
|
|
|
+ YEAR(hr.CheckInDate) AS YEAR,
|
|
|
+ MONTH(hr.CheckInDate) AS MONTH,
|
|
|
+ hr.CheckOutDate,
|
|
|
+ hr.SingleRoomCount,
|
|
|
+ hr.DoubleRoomCount,
|
|
|
+ hr.SuiteRoomCount,
|
|
|
+ hr.OtherRoomCount
|
|
|
+FROM
|
|
|
+ Grp_HotelReservations hr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ AND CTable = 85
|
|
|
+ LEFT JOIN Sys_SetData sd ON hr.ReservationsWebsite = sd.Id
|
|
|
+WHERE
|
|
|
+ hr.IsDel = 0
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ORDER BY
|
|
|
+ hr.CheckInDate
|
|
|
+");
|
|
|
+
|
|
|
+ var data = await _sqlSugar.SqlQueryable<StatisticsHotelView>(sql).ToListAsync();
|
|
|
+
|
|
|
+ var hotelData = data.OrderBy(x => x.CityStr).ToList();
|
|
|
+
|
|
|
+ var airTicketNumData = new List<AirTicketReturnView>();
|
|
|
+ var airTicketAreaData = new List<AirTicketCityReturnView>();
|
|
|
+
|
|
|
+ int monthIndex = 1;
|
|
|
+ while (monthIndex < 13)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ monthIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功!", new { hotelData = hotelData, airTicketAreaData = airTicketAreaData }));
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|