Explorar el Código

统计报表 - 酒店 --> 新增国家top10 API编写;

LEIYI hace 3 meses
padre
commit
8b971f62e9

+ 0 - 1
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -4477,7 +4477,6 @@ FROM
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-
         public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
         {
             var expression = Expressionable.Create<Grp_GroupModelFile>()

+ 27 - 3
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -4105,6 +4105,7 @@ WHERE
 
 SELECT
   hr.DIId,
+  ntf.Country,
   hr.City,
   hr.HotelName,
   sd.Name AS BookinSite,
@@ -4123,6 +4124,7 @@ FROM
   AND CTable = 76
   INNER JOIN Grp_DelegationInfo di ON hr.DiId = di.Id
   LEFT JOIN Sys_SetData sd ON hr.ReservationsWebsite = sd.Id
+  LEFT JOIN Grp_NationalTravelFee ntf ON hr.AreaId = ntf.Id 
 WHERE
   hr.IsDel = 0
   AND di.TeamDid IN (38,39,40,1048)
@@ -4150,9 +4152,32 @@ WHERE
 ORDER BY
   hr.CheckInDate
 ", beginDt, endDt);
-
             var data = await _sqlSugar.SqlQueryable<StatisticsHotelView>(sql).ToListAsync();
 
+            var hotelCountryGroupByData = data.GroupBy(x => x.Country)
+                                            .Select(g => new
+                                            {
+                                                Country = g.Key,
+                                                BookingRoomNum = g.Sum(x => x.RoomTotal),
+                                                hotelData = g.GroupBy(x => x.HotelName)
+                                                             .Select(g1 => new
+                                                             {
+                                                                 hotelName = g1.Key,
+                                                                 roomNights = g1.Sum(x => x.RoomNights),
+                                                                 roomTotal = g1.Sum(x => x.RoomTotal),
+                                                                 singleRoomCount = g1.Sum(x => x.SingleRoomCount),
+                                                                 doubleRoomCount = g1.Sum(x => x.DoubleRoomCount),
+                                                                 suiteRoomCount = g1.Sum(x => x.SuiteRoomCount),
+                                                                 otherRoomCount = g1.Sum(x => x.OtherRoomCount),
+                                                             })
+                                                             .ToList(),
+                                                linkGroupIds = g.Select(x => x.DIId).Distinct().ToList()
+
+                                            })
+                                             .OrderByDescending(x => x.BookingRoomNum)
+                                             .Take(10)
+                                             .ToList();
+
             var hotelData = data.OrderBy(x => x.CityStr).ToList();
 
             var hotelCityGroupByData = data.GroupBy(x => x.CityStr)
@@ -4202,8 +4227,7 @@ ORDER BY
                                                .OrderByDescending(x => x.BookingRoomNum)
                                                .ToList();
 
-
-            return Ok(JsonView(true, "操作成功!", new { hotelCityData = hotelCityGroupByData , hotelPlatformData = hotelPlatformGroupByData }));
+            return Ok(JsonView(true, "操作成功!", new { hotelCountryGroupByData = hotelCountryGroupByData, hotelCityData = hotelCityGroupByData, hotelPlatformData = hotelPlatformGroupByData }));
         }
 
         /// <summary>

+ 1 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -854,6 +854,7 @@ namespace OASystem.Domain.ViewModels.Financial
     public class StatisticsHotelView
     {
         public int DIId { get; set; }
+        public string Country { get; set; }
         public string City { get; set; }
         public string CityStr
         {