瀏覽代碼

统计 酒店、商邀

amigotrip 7 月之前
父節點
當前提交
a4516d1776

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

@@ -9228,7 +9228,6 @@ namespace OASystem.API.Controllers
             }));
         }
 
-
         /// <summary>
         ///  团组成本 各模块(酒店,地接,机票)成本提示
         /// </summary>

+ 101 - 14
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -3677,16 +3677,22 @@ WHERE
 
 
         /// <summary>
-        ///  国交数据统计-酒店相关、商要邀请
-        ///  酒店预订地区TOP10排序、酒店房型地区间数、商邀邀请国家数量TOP10
+        ///  国交数据统计
+        ///  酒店预订地区TOP10
         /// </summary>
         /// <param name="_dto"></param>
         /// <returns></returns>
         [HttpPost("StatisticsHotel")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> StatisticsHotel()
+        public async Task<IActionResult> StatisticsHotel(YOYDto _dto)
         {
 
+            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
   hr.DIId,
@@ -3705,31 +3711,112 @@ FROM
   Grp_HotelReservations hr
   INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
   AND ccp.IsDel = 0
-  AND CTable = 85
+  AND CTable = 76
   LEFT JOIN Sys_SetData sd ON hr.ReservationsWebsite = sd.Id
 WHERE
   hr.IsDel = 0
   AND ccp.IsPay = 1
+  AND (
+    hr.SingleRoomCount > 0
+    OR hr.DoubleRoomCount > 0
+    OR hr.SuiteRoomCount > 0
+    OR hr.OtherRoomCount > 0
+  )
+  AND CHARINDEX('早餐',hr.HotelName) = 0
+  AND CHARINDEX('晚餐',hr.HotelName) = 0
+  AND CHARINDEX('升级',hr.HotelName) = 0
+  AND CHARINDEX('饮料茶水费',hr.HotelName) = 0
+  AND CHARINDEX('城市税',hr.HotelName) = 0
+  AND CHARINDEX('退款',hr.HotelName) = 0
+  AND CHARINDEX('返现',hr.HotelName) = 0
+  AND CHARINDEX('会议室',hr.HotelName) = 0
+  AND CHARINDEX('迷你吧消费',hr.HotelName) = 0
+  AND CHARINDEX('运费',hr.HotelName) = 0
+  AND CHARINDEX('地接',hr.HotelName) = 0
+  AND CHARINDEX('损失',hr.HotelName) = 0
+  AND CHARINDEX('补差',hr.HotelName) = 0
+  AND hr.CheckInDate BETWEEN '{0}' AND '{1}'
 ORDER BY
   hr.CheckInDate
-");
+",beginDt,endDt);
 
             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>();
+            var hotelCityGroupByData = data.GroupBy(x => x.CityStr)
+                                            .Select(g => new
+                                            {
+                                                city = 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();
+
+            return Ok(JsonView(true, "操作成功!", hotelCityGroupByData));
+        }
 
-            int monthIndex = 1;
-            while (monthIndex < 13)
-            {
-               
+        /// <summary>
+        ///  国交数据统计
+        ///  商邀邀请国家数量TOP10
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost("StatisticsInvitation")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> StatisticsInvitation(YOYDto _dto)
+        {
 
-                monthIndex++;
-            }
+            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
+  ioa.DiId,
+  ioa.InviterArea AS Country
+FROM
+  Grp_InvitationOfficialActivities ioa
+  INNER JOIN Grp_CreditCardPayment ccp ON ioa.Id = ccp.CId
+  AND ccp.IsDel = 0
+  AND ccp.CTable = 81
+WHERE
+  ioa.IsDel = 0
+  AND ccp.IsPay = 1
+  AND ioa.CreateTime BETWEEN '{0}' AND '{1}'
+", beginDt, endDt);
+
+            var data = await _sqlSugar.SqlQueryable<StatisticsInvitation>(sql).ToListAsync();
+
+            var groupByData = data.GroupBy(x => x.Country)
+                                  .Select(g => new
+                                  {
+                                        Country = g.Key,
+                                        TimeNum = g.Count(),
+                                        LinkGroupIds = g.Select(x => x.DIId).ToList()
+
+                                  })
+                                  .OrderByDescending(x => x.TimeNum)
+                                  .Take(10)
+                                  .ToList();
 
-            return Ok(JsonView(true, "操作成功!", new { hotelData = hotelData, airTicketAreaData = airTicketAreaData }));
+            return Ok(JsonView(true, "操作成功!", groupByData));
         }
 
         #endregion

+ 40 - 4
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -848,8 +848,6 @@ namespace OASystem.Domain.ViewModels.Financial
 
     #endregion
 
-    #region 国交数据统计-酒店相关、商要邀请
-
     #region 酒店
     public class StatisticsHotelView
     {
@@ -859,7 +857,7 @@ namespace OASystem.Domain.ViewModels.Financial
         {
             get
             {
-                return City.Replace(" ","").ToUpper();
+                return City.Replace(" ", "").ToUpper();
             }
         }
         public string HotelName { get; set; }
@@ -873,9 +871,36 @@ namespace OASystem.Domain.ViewModels.Financial
         public int SuiteRoomCount { get; set; }
         public int OtherRoomCount { get; set; }
 
+        public int RoomNights
+        {
+            get
+            {
+                int nights = 0;
+                if (!string.IsNullOrEmpty(CheckInDate) && !string.IsNullOrEmpty(CheckOutDate))
+                {
+                    DateTime checkin, checkout;
+                    bool checkInBool = DateTime.TryParse(CheckInDate, out checkin);
+                    bool checkOutBool = DateTime.TryParse(CheckOutDate, out checkout);
+                    if (checkInBool && checkOutBool)
+                    {
+                        nights = (checkout - checkin).Days * RoomTotal;
+                    }
+                }
+                return nights;
+            }
+        }
+
+        public int RoomTotal
+        {
+            get
+            {
+                return SingleRoomCount + DoubleRoomCount + SuiteRoomCount + OtherRoomCount;
+            }
+        }
+
         public StatisticsHotelView() { }
 
-        public StatisticsHotelView(int diid,string city,string hotelName,string bookingSite, string checkIn, string checkOut,int singleRoom,int doubleRoomCount,int suiteRoomCount,int otherRoomCount) 
+        public StatisticsHotelView(int diid, string city, string hotelName, string bookingSite, string checkIn, string checkOut, int singleRoom, int doubleRoomCount, int suiteRoomCount, int otherRoomCount)
         {
             DIId = diid;
             City = city;
@@ -890,8 +915,19 @@ namespace OASystem.Domain.ViewModels.Financial
     }
 
 
+    public class HotelReturnView
+    {
+
+    }
+
     #endregion
 
+    #region 商邀邀请
+    public class StatisticsInvitation
+    {
+        public int DIId { get; set; }
+        public string Country { get; set; }    }
     #endregion
+
     #endregion
 }