Procházet zdrojové kódy

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf před 7 měsíci
rodič
revize
cd261bc943

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

@@ -1870,6 +1870,11 @@ namespace OASystem.API.Controllers
                 }
             }
 
+            if (!string.IsNullOrEmpty(dto.groupName))
+            {
+                sqlWhere += string.Format(@" And di.TeamName Like '%{0}%' ", dto.groupName);
+            }
+
             #endregion
 
             //已收款项 判断如果是市场部的人员进来的话 只显示自己的 其他的都显示全部的
@@ -1886,7 +1891,7 @@ namespace OASystem.API.Controllers
             //排序倒序
             string sql = string.Format(@$"select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate,di.CreateTime from Fin_ForeignReceivables fr join Grp_DelegationInfo di on fr.DIID = di.id {sqlWhere}  {userSqlWhere}  Order By di.VisitDate Desc");
 
-            List<PostSyntheticalReceivableByDateRangeView> list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
+            var list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
 
             var setData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
 

+ 18 - 5
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -5,6 +5,7 @@ using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
 using Org.BouncyCastle.Utilities.Encoders;
 using static OASystem.API.OAMethodLib.JWTHelper;
@@ -2821,15 +2822,27 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 })
                 .ToListAsync();
             var officialDutyData = await _sqlSugar.Queryable<Res_OfficialActivities>()
-                .Where(x => x.IsDel == 0)
-                .Select(x => new {
-                    x.Id,
-                    x.Client,
+                .LeftJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
+                .Where((oa, di) => oa.IsDel == 0)
+                .Select((oa, di) => new
+                {
+                    oa.Id,
+                    oa.Client,
+                    oa.DiId,
+                    di.TeamName
                 })
                 .ToListAsync();
+
+            var officialDutyData1 = officialDutyData.GroupBy(x => x.DiId)
+                .Select(g => new {
+                    id = g.Key,
+                    label = g.FirstOrDefault()?.TeamName ?? "-",
+                    children = g.Select(g1 => new { id = g1.Id, label = g1.Client }).ToList()
+                })
+                .ToList();
             var view = new { 
                 currencyData = currencyData,
-                officialDutyData = officialDutyData
+                officialDutyData = officialDutyData1
             };
 
             return Ok(JsonView(view));

+ 195 - 11
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -4,6 +4,7 @@ using OASystem.Domain.Dtos.Statistics;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
+using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.Groups;
 using System.Data;
@@ -2316,8 +2317,8 @@ ORDER BY
         {
             //全部人员Id
             //查询所有公司的市场部
-            List<int> pickGroupIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).Select(it => it.JietuanOperator).Distinct().ToList();
-            List<int> userIds = new List<int>();
+           var pickGroupIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).Select(it => it.JietuanOperator).Distinct().ToList();
+           var userIds = new List<int>();
             var userDatas = await _sqlSugar.Queryable<Sys_Users>()
                                            .InnerJoin<Sys_Company>((u, c) => u.CompanyId == c.Id)
                                            .Where((u, c) => u.IsDel == 0 && pickGroupIds.Contains(u.Id))
@@ -2462,7 +2463,6 @@ FROM
             public string yoy { get; set; } = "1.00";
         }
 
-
         /// <summary>
         ///  市场部销售额
         ///  团组列表
@@ -2615,6 +2615,132 @@ FROM
             return Ok(JsonView(true, "操作成功!", groupData, total));
         }
 
+        /// <summary>
+        ///  市场部销售额
+        ///  团组列表Excel下载
+        /// </summary>
+        /// <param name="_dto">市场部销售额请求dto</param>
+        /// <returns></returns>
+        [HttpPost("PostMarketingSalesGroupExcel")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostMarketingSalesGroupExcel(MarketingSalesGroupListDto _dto)
+        {
+            #region  参数验证
+
+            MarketingSalesStatisticsDtoFoalidator validationRules = new MarketingSalesStatisticsDtoFoalidator();
+            var validResult = await validationRules.ValidateAsync(_dto);
+            if (!validResult.IsValid)
+            {
+                var errors = new StringBuilder();
+                foreach (var error in validResult.Errors) errors.AppendLine(error.ErrorMessage);
+                return Ok(JsonView(false, errors.ToString()));
+            }
+
+            PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
+
+            #region 页面操作权限验证
+            pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+
+            if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, MsgTips.CheckAuth));
+            #endregion
+
+            #endregion
+
+            string userSql = "";
+            var userIds = new List<int>();
+            userIds = await GetUserIds(_dto.CompanyId, _dto.GroupPickupUserId);
+
+            if (userIds.Count <= 0)
+            {
+                return Ok(JsonView(false));
+            }
+            else userSql = @$" And di.JietuanOperator In ({string.Join(",", userIds)})";
+
+
+            if (!string.IsNullOrEmpty(_dto.SearchCriteria))
+            {
+                userSql += string.Format(@$" AND di.TeamName Like '%{_dto.SearchCriteria}%'");
+            }
+
+            string beginDt = $"{_dto.BeginDt} 00:00:00", 
+                   endDt = $"{_dto.EndDt} 23:59:59";
+
+            string sql = string.Format(@$"SELECT
+  ROW_NUMBER() OVER (
+    ORDER BY
+      CollectionDays
+  ) AS RowNumber,
+  *
+FROM
+  (
+    SELECT
+      di.Id,
+      di.TeamName,
+      di.ClientUnit,
+      di.ClientName,
+      di.VisitDate,
+      di.VisitPNumber,
+      di.JietuanOperator,
+      di.VisitEndDate,
+      (
+        SELECT
+          CAST(
+            COALESCE(SUM(ItemSumPrice * Rate), 0) AS DECIMAL(12, 2)
+          ) AS GroupSales
+        FROM
+          Fin_ForeignReceivables
+        WHERE
+          IsDel = 0
+          AND di.Id = Diid
+          AND AddingWay IN (0, 1, 2)
+      ) AS GroupSales,
+      u.CnName AS GroupPickupUser,
+      DATEADD(DAY, 7, di.VisitEndDate) AS CollectionDays
+    FROM
+      Grp_DelegationInfo di
+    WITH
+      (NoLock)
+      LEFT JOIN Sys_Users u ON di.JietuanOperator = u.Id
+    WHERE
+      di.Isdel = 0
+      AND  (
+        SELECT
+          CAST(
+            COALESCE(SUM(ItemSumPrice * Rate), 0) AS DECIMAL(12, 2)
+          ) AS GroupSales
+        FROM
+          Fin_ForeignReceivables
+        WHERE
+          IsDel = 0
+          AND di.Id = Diid
+          AND AddingWay IN (0, 1, 2)
+      ) > 0
+	   {userSql}  
+      AND VisitDate Between '{beginDt}' And  '{endDt}'
+  ) Temp ");
+            
+            var view = await _sqlSugar.SqlQueryable<MarketingSalesGroupList>(sql).ToListAsync();
+
+
+            if (view.Count < 1 ) return Ok(JsonView(false, "暂无数据!"));
+
+            //DataTable dt = GeneralMethod.
+            DataTable dt = CommonFun.GetDataTableFromIList(view);
+            dt.TableName = $"_view";
+            WorkbookDesigner designer = new WorkbookDesigner();
+            designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/营业额团组报表模板.xls");
+            designer.SetDataSource(dt);
+            designer.SetDataSource("Total", view.Sum(x => x.GroupSales));
+            designer.Workbook.Worksheets[0].Name = "营业额团组报表";
+
+            designer.Process();
+
+            string fileName = $"MarketingSales/{_dto.BeginDt}~{_dto.EndDt}营业额团组报表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
+            designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
+            string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
+            return Ok(JsonView(true, "操作成功", new { url = rst }));
+        }
+
         /// <summary>
         ///  市场部销售额
         ///  客户类型、客户等级 统计
@@ -3685,7 +3811,7 @@ ORDER BY
 
         /// <summary>
         ///  国交数据统计-机票相关
-        ///  1、机票票数、2、机票到达地
+        ///  机票票数、机票到达地、预订平台
         /// </summary>
         /// <param name="_dto"></param>
         /// <returns></returns>
@@ -3709,7 +3835,12 @@ SELECT
   sd.Name As CTypeName,
   atr.FlightsCity,
   atr.ClientNum,
-  atr.ClientName
+  atr.ClientName,
+  di.TeamName As 'GroupName',
+  CASE 
+    WHEN ccp.Payee = '' OR ccp.Payee IS NULL THEN '未知'
+    ELSE ccp.Payee
+  END AS 'Platform'
 FROM
   Grp_AirTicketReservations atr
   INNER JOIN Grp_CreditCardPayment ccp ON atr.Id = ccp.CId
@@ -3720,7 +3851,7 @@ FROM
 WHERE
   atr.IsDel = 0
   AND di.TeamDid IN (38,39,40,1048)
-  And atr.CType IN(457,458,459,460,574,575)
+  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
@@ -3808,7 +3939,7 @@ WHERE
 
                 //机票城市处理
                 //城市处理
-                List<string> airTicketCityInfos = new List<string>();
+                var airTicketCityInfos = new List<string>();
                 foreach (var item in monthData)
                 {
                     if (!string.IsNullOrEmpty(item.FlightsCityName))
@@ -3850,12 +3981,41 @@ WHERE
                 monthIndex++;
             }
 
-            return Ok(JsonView(true, "操作成功!", new { airTicketNumData = airTicketNumData, airTicketAreaData = airTicketAreaData }));
+            var airTicketPlatformData = data.GroupBy(g => g.Platform)
+                .Select(g => new
+                {
+                    platform = g.Key,
+                    total = g.Sum(x => x.ClientNum),
+                    children = g.GroupBy(g1 => g1.DIId)
+                                .Select(g1 => new { 
+                                    diId = g1.Key,
+                                    groupName = g1.FirstOrDefault()?.GroupName ?? "-",
+                                    total = g1.Sum(x1 => x1.ClientNum),
+                                    children = g1.Select(x1 => new {
+                                        //diId = x1.DIId,
+                                        //groupName = x1.GroupName,
+                                                  flightsCityName=x1.FlightsCityName,
+                                                  total = x1.ClientNum
+                                                 })
+                                                 .ToList()
+                                })
+                                .OrderByDescending(x1 => x1.total)
+                                .ToList()
+                })
+                .OrderByDescending(x => x.total)
+                .ToList();
+
+            return Ok(JsonView(true, "操作成功!", new
+            {
+                airTicketNumData = airTicketNumData,
+                airTicketAreaData = airTicketAreaData,
+                airTicketPlatformData = airTicketPlatformData
+            }));
         }
 
         /// <summary>
-        ///  国交数据统计
-        ///  酒店预订地区TOP10
+        ///  国交数据统计-酒店
+        ///  地区TOP10、预订平台
         /// </summary>
         /// <param name="_dto"></param>
         /// <returns></returns>
@@ -3948,7 +4108,31 @@ ORDER BY
                                              .Take(10)
                                              .ToList();
 
-            return Ok(JsonView(true, "操作成功!", hotelCityGroupByData));
+            var hotelPlatformGroupByData = data.GroupBy(x => x.BookinSite)
+                                               .Select(g => new
+                                               {
+                                                   Platform = 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)
+                                               .ToList();
+
+
+            return Ok(JsonView(true, "操作成功!", new { hotelCityData = hotelCityGroupByData , hotelPlatformData = hotelPlatformGroupByData }));
         }
 
         /// <summary>

+ 5 - 0
OASystem/OASystem.Domain/Dtos/Financial/PostSyntheticalReceivableByDateRangeDto.cs

@@ -13,6 +13,11 @@ namespace OASystem.Domain.Dtos.Financial
         public string beginDt { get; set; }
         public string endDt { get; set; }
 
+        /// <summary>
+        /// 团组名称
+        /// </summary>
+        public string groupName { get; set; }
+
         /// <summary>
         /// 请求类型:1:查询数据,2:生成Excel
         /// </summary>

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

@@ -744,6 +744,8 @@ namespace OASystem.Domain.ViewModels.Financial
         public string FlightsCity { get; set; }
         public string FlightsCityName { get; set; }
         public int ClientNum { get; set; }
+        public string GroupName { get; set; }
+        public string Platform { get; set; }
     }
 
     public class AirTicketReturnView
@@ -829,7 +831,6 @@ namespace OASystem.Domain.ViewModels.Financial
             this.Quantity = quantity;
 
         }
-
     }
 
     public class AirTicketCityInfo

+ 24 - 4
OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs

@@ -51,8 +51,16 @@ namespace OASystem.Infrastructure.Repositories.Financial
             var setData = _setDataTypeRep.QueryDto<Sys_SetData, Fin_DailyFeePaymentPagePriceSubTypeView>().ToList();
 
             //48人员费用  49办公费用 50 销售费用 51 其他费用 55 大运会
-            var priceTypeData = setTypeData.Where(s => s.Id == 48 || s.Id == 49 || s.Id == 50 || s.Id == 51 || s.Id == 55).ToList();
-            var priceSubTypeData = setData.Where(s => s.STid == 48 || s.STid == 49 || s.STid == 50 || s.STid == 51 || s.STid == 55).ToList();
+            var typeIds = new List<int>() {
+                48, //人员费用
+                49, //办公费用
+                50, //销售费用
+                51, //其他费用
+                55, //大运会
+                //90, //各部门基础固定费用明细
+            };
+            var priceTypeData = setTypeData.Where(s => typeIds.Contains(s.Id)).ToList();
+            var priceSubTypeData = setData.Where(s => typeIds.Contains(s.STid)).ToList();
 
             var isEnable = false;
             //员工姓名列表
@@ -275,7 +283,6 @@ namespace OASystem.Infrastructure.Repositories.Financial
                                                 ) temp ", sqlWhere);
             #endregion
 
-
             if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
                 //Fin_DailyFeePaymentPageCount
@@ -361,6 +368,20 @@ namespace OASystem.Infrastructure.Repositories.Financial
             {
                 Fin_DailyFeePayment _fee = _mapper.Map<Fin_DailyFeePayment>(dto);
                 _fee.CreateUserId = dto.UserId;
+
+                /*
+                 * 2024-10-29
+                 * 各部门基础固定费用明细”里的费用数据新增后,财务和总经理审核都默认直接通过isAudit=1),并且可编辑,如果ispay=1的话将不可编辑
+                 */
+                var priceTypeInfo = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == dto.PriceTypeId).FirstAsync();
+                if (priceTypeInfo != null && priceTypeInfo.STid == 90)
+                {
+                    _fee.FAudit = 1;
+                    _fee.FAuditDate = DateTime.Now;
+                    _fee.MAudit = 1;
+                    _fee.MAuditDate = DateTime.Now;
+                }
+
                 int? feeId = await _sqlSugar.Insertable(_fee).ExecuteReturnIdentityAsync();
 
                 if (dto.FeeContents.Count > 0)
@@ -426,7 +447,6 @@ namespace OASystem.Infrastructure.Repositories.Financial
                     result.Msg = "审核已通过,不可修改!";
                     return result;
                 }
-
             }
 
             #endregion

+ 0 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/AirTicketResRepository.cs

@@ -323,7 +323,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                 #region 团组下拉框
 
-
                 List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 85).ToList();
                 List<GroupNameView> grp_NameView = new List<GroupNameView>();
                 string DiId = "";