Browse Source

团组成本 各模块(酒店,地接,机票)成本提示
新增邀请相关提示费用

amigotrip 9 months ago
parent
commit
a871dd7494

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

@@ -2063,6 +2063,7 @@ namespace OASystem.API.Controllers
                 248, // 非团组
                 691, // 四川-会务活动
                 762, // 四川-赛事项目收入
+                1048,//高校团
             };
             List<int> _ChengDu = new List<int>() {
                 302,  // 成都-会务活动

+ 15 - 7
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -7864,6 +7864,8 @@ namespace OASystem.API.Controllers
             var di = deleInfo.Data as DelegationInfoWebView;
             if (di != null)
             {
+                di.TeamName = di.TeamName.Replace("|","、");
+                di.VisitCountry = di.VisitCountry.Replace("|", "、");
                 //文件名
                 string strFileName = di.TeamName + "-收款账单.doc";
                 //获取模板
@@ -9449,11 +9451,16 @@ namespace OASystem.API.Controllers
                                     Breakfast = it.B * _rate * _scale,            //早餐费
                                     Lunch = it.L * _rate * _scale,                //午餐费
                                     Dinner = it.D * _rate * _scale,               //晚餐费
+                                    OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
+                                    OfficialTransFee = it.IF * _rate * _scale,    //公务翻译费 --新加
+                                    InvitationFee = it.iL * _rate * _scale,       //邀请函费用 --新加
                                     TicketFee = it.EF * _rate * _scale,           //门票费 
-                                    SpentCash = it.PC * _rate * _scale,           //零用金
-                                    LeadersFee = it.TLF * _rate * _scale,         //领队费
+                                    TicketRemark = it.EFR,                        //门票费描述 
                                     DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
                                     TravelSupplies = it.TE * _rate * _scale,      //出行物资
+                                    SpentCash = it.PC * _rate * _scale,           //零用金
+                                    LeadersFee = it.TLF * _rate * _scale,         //领队费
+                                    ActivitiesFee = it.ECT * _rate * _scale,      //会务费 --新加
                                 })
                             );
                             break;
@@ -10481,7 +10488,7 @@ ORDER by  gctggrc.id DESC
                 var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
 
 
-                string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
+                string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
 
                 string singleRoomFeeStr = string.Empty,
                        doubleRoomFeeStr = string.Empty,
@@ -10518,6 +10525,7 @@ ORDER by  gctggrc.id DESC
                 governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
                 cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
 
+                int payDId = roomInfo?.PayDId ?? 0;
                 pcfds.Add(new HotelReservations_PCFD_View()
                 {
                     City = item.City,
@@ -10537,12 +10545,12 @@ ORDER by  gctggrc.id DESC
                     CityTax = cityTaxStrStr,
 
                     RoomExplanation = item.RoomExplanation,
-                    PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
-                    PayTime = roomInfo.ConsumptionDate,
-                    BankNo = roomInfo.BankNo,
+                    PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
+                    PayTime = roomInfo?.ConsumptionDate,
+                    BankNo = roomInfo?.BankNo,
                     PayMoney = payMoneyStr,
                     //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
-                    ConsumptionPatterns = roomInfo.ConsumptionPatterns,
+                    ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
                     CardPrice = cardPriceStr,
                     Remark = ccpInfo.Remark
 

+ 228 - 16
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -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
     }
 }

+ 12 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_GroupCost.cs

@@ -346,6 +346,18 @@ namespace OASystem.Domain.Entities.Groups
             set { ef = value; }
         }
 
+        string efr;
+        /// <summary>
+        /// 景点门票 描述
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(200)")]
+        public string EFR
+        {
+            get { return efr; }
+            set { efr = value; }
+        }
+
+
         decimal brf;
         /// <summary>
         /// 饮料零食水果

+ 178 - 3
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -1,4 +1,5 @@
-using Npgsql.Replication.PgOutput;
+using Dm;
+using Npgsql.Replication.PgOutput;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.ViewModels.System;
 using System;
@@ -561,7 +562,7 @@ namespace OASystem.Domain.ViewModels.Financial
     [SqlSugar.SugarTable("Fin_DailyFeePaymentContent")]
     public class DailyFeePaymentContentView
     {
-        
+
         //[SugarColumn(IsIgnore = true)]//需要加上
         //public int RowIndex { get; set; } //行号 序号
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
@@ -605,6 +606,8 @@ namespace OASystem.Domain.ViewModels.Financial
 
     #region 统计模块
 
+    #region YOY
+
     public class StatisticsYOYView
     {
         public int Id { get; set; }
@@ -698,6 +701,16 @@ namespace OASystem.Domain.ViewModels.Financial
 
         public List<int> ThisIds { get; set; }
         public List<int> LastIds { get; set; }
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="year"></param>
+        /// <param name="month"></param>
+        /// <param name="thisAmount"></param>
+        /// <param name="lastAmount"></param>
+        /// <param name="thisIds"></param>
+        /// <param name="lastIds"></param>
         public YOYReturnView(int year, int month, decimal thisAmount, decimal lastAmount, List<int> thisIds, List<int> lastIds)
         {
             this.Year = year;
@@ -716,7 +729,169 @@ namespace OASystem.Domain.ViewModels.Financial
         }
     }
 
-    
+    #endregion
+
+    #region 国交数据统计 - 机票
+
+    public class StatisticsAirTicketView
+    {
+        public int DIId { get; set; }
+        public DmDateTime FlightsDate { get; set; }
+        public int Year { get; set; }
+        public int Month { get; set; }
+        public int CType { get; set; }
+        public string CTypeName { get; set; }
+        public string FlightsCity { get; set; }
+        public string FlightsCityName { get; set; }
+        public int ClientNum { get; set; }
+    }
+
+    public class AirTicketReturnView
+    {
+        public int Year { get; set; }
+        public int Month { get; set; }
+
+        /// <summary>
+        /// 票数
+        /// </summary>
+        public int Quantity { get; set; }
+
+        public List<AitTicketInfo> AitTicketInfos { get; set; }
+
+
+        public List<int> LinkGroupIds { get; set; }
+
+
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="year"></param>
+        /// <param name="month"></param>
+        /// <param name="quantity"></param>
+        /// <param name="linkGroupIds"></param>
+        public AirTicketReturnView(int year, int month, int quantity, List<AitTicketInfo> aitTicketInfos, List<int> linkGroupIds)
+        {
+            this.Year = year;
+            this.Month = month;
+            this.Quantity = quantity;
+            this.AitTicketInfos = aitTicketInfos;
+            this.LinkGroupIds = linkGroupIds;
+        }
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="year"></param>
+        /// <param name="month"></param>
+        /// <param name="quantity"></param>
+        /// <param name="linkGroupIds"></param>
+        public AirTicketReturnView(int year, int month, int quantity, List<int> linkGroupIds)
+        {
+            this.Year = year;
+            this.Month = month;
+            this.Quantity = quantity;
+            this.LinkGroupIds = linkGroupIds;
+        }
+    }
+
+
+    public class AirTicketCityReturnView : AirTicketReturnView
+    {
+        public List<AirTicketCityInfo> CityData { get; set; }
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="year"></param>
+        /// <param name="month"></param>
+        /// <param name="quantity"></param>
+        /// <param name="linkGroupIds"></param>
+        public AirTicketCityReturnView(int year, int month, int quantity, List<AirTicketCityInfo> cityData, List<int> linkGroupIds)
+            : base(year, month, quantity, linkGroupIds)
+        {
+            this.Year = year;
+            this.Month = month;
+            this.Quantity = quantity;
+            this.CityData = cityData;
+            this.LinkGroupIds = linkGroupIds;
+        }
+    }
+    public class AitTicketInfo
+    {
+        public int Id { get; set; }
+
+        public string GroupName { get; set; }
+
+        public int Quantity { get; set; }
+
+        public AitTicketInfo(int id, string groupName, int quantity)
+        {
+            this.Id = id;
+            this.GroupName = groupName;
+            this.Quantity = quantity;
+
+        }
+
+    }
+
+    public class AirTicketCityInfo
+    {
+        public string City { get; set; }
 
+        public int Quantity { get; set; }
+
+        public AirTicketCityInfo(string city, int quantity = 0)
+        {
+            City = city;
+            Quantity = quantity;
+        }
+    }
+
+
+    #endregion
+
+    #region 国交数据统计-酒店相关、商要邀请
+
+    #region 酒店
+    public class StatisticsHotelView
+    {
+        public int DIId { get; set; }
+        public string City { get; set; }
+        public string CityStr
+        {
+            get
+            {
+                return City.Replace(" ","").ToUpper();
+            }
+        }
+        public string HotelName { get; set; }
+        public string BookinSite { get; set; }
+        public string CheckInDate { get; set; }
+        //public int Year { get; set; }
+        //public int Month { get; set; }
+        public string CheckOutDate { get; set; }
+        public int SingleRoomCount { get; set; }
+        public int DoubleRoomCount { get; set; }
+        public int SuiteRoomCount { get; set; }
+        public int OtherRoomCount { get; set; }
+
+        public StatisticsHotelView() { }
+
+        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;
+            BookinSite = bookingSite;
+            CheckInDate = checkIn;
+            CheckOutDate = checkOut;
+            SingleRoomCount = singleRoom;
+            DoubleRoomCount = doubleRoomCount;
+            SuiteRoomCount = suiteRoomCount;
+            OtherRoomCount = otherRoomCount;
+        }
+    }
+
+
+    #endregion
+
+    #endregion
     #endregion
 }

+ 2 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -369,6 +369,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).FirstAsync();
                 if (_DelegationInfo != null)
                 {
+                    _DelegationInfo.TeamName = FormartTeamName(_DelegationInfo.TeamName);
+                    _DelegationInfo.VisitCountry = FormartTeamName(_DelegationInfo.VisitCountry);
                     result.Code = 0;
                     result.Msg = "成功!";
                     result.Data = _DelegationInfo;