Parcourir la source

优化审核逻辑及参数验证

在 `FinancialController.cs` 中,注释掉了旧的日期参数验证和 SQL 查询条件,添加了新的日期验证逻辑,并调整了市场部用户的处理方式。
在 `PersonnelModuleController.cs` 中,修改了 `GoodsReceiveBatchList` 方法的参数命名,并添加了用户信息验证。
在 `Fin_ForeignReceivablesView.cs` 中,增加了关于是否显示红色的注释。
在 `GoodsInfoView.cs` 中,新增了 `AuditPers` 属性和 `IsValuable` 属性。
在 `FeeAuditRepository.cs` 中,重构了费用审核逻辑,增加了机票费用的自动审核处理及撤销功能。
在 `GoodsRepository.cs` 中,增加了对普通物品和贵重物品的审核模板处理逻辑。
LEIYI il y a 4 jours
Parent
commit
676411195d

+ 73 - 52
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -1874,60 +1874,89 @@ namespace OASystem.API.Controllers
         public async Task<IActionResult> PostSyntheticalReceivableByDateRange(PostSyntheticalReceivableByDateRangeDto dto)
         {
 
-            string sqlWhere = " Where di.IsDel=0 ";
+            #region 老版查询
+            //string sqlWhere = " Where di.IsDel=0 ";
 
-            #region 验证
-            if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
-            {
-                return Ok(JsonView(false, "日期参数至少填写一个!"));
-            }
+            //#region 验证
+            //if (string.IsNullOrEmpty(dto.beginDt) && string.IsNullOrEmpty(dto.endDt))
+            //{
+            //    return Ok(JsonView(false, "日期参数至少填写一个!"));
+            //}
 
-            if (!string.IsNullOrEmpty(dto.beginDt))
-            {
-                if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
-                {
-                    return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
-                }
-                else
-                {
-                    sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
-                }
-            }
+            //if (!string.IsNullOrEmpty(dto.beginDt))
+            //{
+            //    if (Regex.Match(dto.beginDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
+            //    {
+            //        return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
+            //    }
+            //    else
+            //    {
+            //        sqlWhere += string.Format(@" And di.VisitDate >= '{0} 00:00:00' ", dto.beginDt);
+            //    }
+            //}
 
-            if (!string.IsNullOrEmpty(dto.endDt))
-            {
-                if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
-                {
-                    return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
-                }
-                else
-                {
-                    sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
-                }
-            }
+            //if (!string.IsNullOrEmpty(dto.endDt))
+            //{
+            //    if (Regex.Match(dto.endDt, @"^\d{4}-\d{2}-\d{2}$").Value.Length < 1)
+            //    {
+            //        return Ok(JsonView(false, "日期参数格式错误,应为yyyy-MM-dd!"));
+            //    }
+            //    else
+            //    {
+            //        sqlWhere += string.Format(@" And di.VisitDate <= '{0} 23:59:59' ", dto.endDt);
+            //    }
+            //}
 
-            if (!string.IsNullOrEmpty(dto.groupName))
-            {
-                sqlWhere += string.Format(@" And di.TeamName Like '%{0}%' ", dto.groupName);
-            }
+            //if (!string.IsNullOrEmpty(dto.groupName))
+            //{
+            //    sqlWhere += string.Format(@" And di.TeamName Like '%{0}%' ", dto.groupName);
+            //}
 
-            #endregion
+            //#endregion
 
-            //已收款项 判断如果是市场部的人员进来的话 只显示自己的 其他的都显示全部的
-            string userSqlWhere = "";
-            var userInfos = await _sqlSugar.Queryable<Sys_Users>()
-                                           .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
-                                           .Where((u, d) => u.IsDel == 0 && d.DepName.Contains("市场部") && u.Id == dto.CurrUserId)
-                                           .ToListAsync();
+            ////已收款项 判断如果是市场部的人员进来的话 只显示自己的 其他的都显示全部的
+            //string userSqlWhere = "";
+            //var userInfos = await _sqlSugar.Queryable<Sys_Users>()
+            //                               .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
+            //                               .Where((u, d) => u.IsDel == 0 && d.DepName.Contains("市场部") && u.Id == dto.CurrUserId)
+            //                               .ToListAsync();
+
+            //if (userInfos.Count > 0) userSqlWhere = string.Format(@$" And JietuanOperator={dto.CurrUserId} ");
 
 
-            if (userInfos.Count > 0) userSqlWhere = string.Format(@$" And JietuanOperator={dto.CurrUserId} ");
+            ////排序倒序
+            //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");
 
+            //var list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
+            #endregion
 
-            //排序倒序
-            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");
+            //日期验证
+            var startTimeFlag = DateTime.TryParse(dto.beginDt, out DateTime begintime);
+            var endTimeFlag = DateTime.TryParse(dto.endDt, out DateTime endtime);
+            if (!startTimeFlag || !endTimeFlag) return Ok(JsonView(false, "请输入正确的开始、结束时间!"));
 
-            var list_rst = _sqlSugar.SqlQueryable<PostSyntheticalReceivableByDateRangeView>(sql).ToList();
+            string groupName = dto.groupName;
+            int currUserId = dto.CurrUserId;
+
+            //已收款项 判断如果是市场部的人员进来的话 只显示自己的 其他的都显示全部的
+            var marketStaffFlag = await _sqlSugar.Queryable<Sys_Users>()
+                .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
+                .Where((u, d) => u.IsDel == 0 && d.DepName.Contains("市场部") && u.Id == dto.CurrUserId)
+                .AnyAsync();
+
+            var list_rst = await _sqlSugar.Queryable<Grp_DelegationInfo>()
+                .Where(x => x.IsDel == 0)
+                .WhereIF(startTimeFlag && endTimeFlag, x => x.VisitDate >= begintime && x.VisitDate <= endtime)
+                .WhereIF(!string.IsNullOrEmpty(groupName), x=> x.TeamName.Contains(groupName))
+                .WhereIF(marketStaffFlag, x => x.JietuanOperator == currUserId)
+                .OrderBy(x => x.VisitDate)
+                .Select(x => new PostSyntheticalReceivableByDateRangeView() { 
+                    diid = x.Id,
+                    teamName = x.TeamName,
+                    clientUnit = x.ClientUnit,
+                    visitDate = x.VisitDate.ToString("yyyy-MM-dd")
+                })
+                .ToListAsync();
 
             var setData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
 
@@ -1935,19 +1964,11 @@ namespace OASystem.API.Controllers
             decimal sumAll_pr = 0M; //已收
             decimal sumAll_balance = 0M; //尾款
             var result = new PostSyntheticalReceivableByDateRangeResultView();
-            if (list_rst.Count > 0)
+            if (list_rst.Any())
             {
                 int rowNumber = 1;
                 foreach (var item_rst in list_rst)
                 {
-                    DateTime dtTemp;
-                    bool b = DateTime.TryParse(item_rst.visitDate, out dtTemp);
-                    if (b)
-                    {
-                        item_rst.visitDate = dtTemp.ToString("yyyy-MM-dd");
-                    }
-
-
                     item_rst.No = rowNumber;
                     rowNumber++;
 

+ 11 - 3
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -2358,9 +2358,18 @@ WHERE
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GoodsReceiveBatchList(GoodsReceiveBatchListDto Dto)
+        public async Task<IActionResult> GoodsReceiveBatchList(GoodsReceiveBatchListDto dto)
         {
-            return Ok(await _goodsRep.GoodsReceiveBatchListAsync(Dto));
+            var currUserId = dto.CurrUserId;
+            var userInfo = await _sqlSugar.Queryable<Sys_Users>().FirstAsync(x => x.IsDel == 0 && x.Id == currUserId);
+            if (userInfo == null)
+            {
+                var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+                if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+                dto.CurrUserId = currUserInfo.UserId;
+            }
+
+            return Ok(await _goodsRep.GoodsReceiveBatchListAsync(dto));
         }
 
         /// <summary>
@@ -2376,7 +2385,6 @@ WHERE
             return Ok(await _goodsRep.GoodsReceiveBatchInfoAsync(id));
         }
 
-
         /// <summary>
         /// 物资进销存
         /// 领用 审核 含批量领用

+ 7 - 0
OASystem/OASystem.Domain/ViewModels/Financial/Fin_ForeignReceivablesView.cs

@@ -349,6 +349,13 @@ namespace OASystem.Domain.ViewModels.Financial
         /// </summary>
         public string visitDate { get; set; }
 
+        ///// <summary>
+        ///// 是否显示红色
+        ///// true : 是
+        ///// false : 否
+        ///// </summary>
+        //public bool isShowRed { get; set; } = false;
+
         /// <summary>
         /// 应收
         /// </summary>

+ 8 - 0
OASystem/OASystem.Domain/ViewModels/PersonnelModule/GoodsInfoView.cs

@@ -201,6 +201,7 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
         public string GoodsType { get; set; }
 
         public string GoodsDetails { get; set; }
+        public GoodsStorageAuditPerView[] AuditPers { get; set; }
 
     }
 
@@ -209,7 +210,14 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
 
         public int GoodsTypeId { get; set; }
 
+        /// <summary>
+        /// 是否贵重物品
+        /// true:贵重物品
+        /// false:非贵重物品
+        /// </summary>
         public bool IsValuable { get; set; } = false;
+
+        //public GoodsStorageAuditPerView[] AuditPers { get; set; }
     }
 
     /// <summary>

+ 225 - 45
OASystem/OASystem.Infrastructure/Repositories/Groups/FeeAuditRepository.cs

@@ -5,6 +5,7 @@ using OASystem.Domain;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Groups;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -31,6 +32,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// 2.op 79
         /// 3.其他费用-出行物资 98
         /// 4.保险 82
+        /// 5.机票 85
         /// </param>
         /// <param name="diId">团组Id</param>
         /// <param name="dataId">数据Id(模块类型主表Id)</param>
@@ -41,22 +43,31 @@ namespace OASystem.Infrastructure.Repositories.Groups
             if (diId < 1) { _view.Msg = MsgTips.DiId; return _view; }
             if (dataId < 1) { _view.Msg = MsgTips.Id; return _view; }
 
+            var groupDetails = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).First();
+            if (groupDetails == null)
+            {
+                _view.Msg = $"团组信息为空,不可自动审核!";
+                return _view;
+            }
+
             var stids = new List<int>() { 17, 66, 91 };
             var setData = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && stids.Contains(x.STid)).ToList();
-            string _teamCurrency = string.Empty;
 
-            decimal _teamRate = 0.00M;
-            var costContents = new List<GroupCostAuditView>();
-            if (feeType != 4)
-            {
-                var groupInfo = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(x => x.IsDel == 0 && x.DiId == diId).First();
-                if (groupInfo == null) { _view.Msg = $"团组成本信息未填写!"; return _view; }
-                _teamCurrency = groupInfo.Currency;
-                _teamRate = groupInfo.Rate;
+            var groupInfo = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(x => x.IsDel == 0 && x.DiId == diId).First();
+            if (groupInfo == null) { _view.Msg = $"团组成本信息未填写!"; return _view; }
+            string _teamCurrency = groupInfo.Currency;
+            decimal _teamRate = groupInfo.Rate;
 
-                //币种验证  统一为currencycode三字码
-                if (int.TryParse(_teamCurrency, out int currency)) _teamCurrency = setData.Find(x => x.Id == currency)?.Name ?? "";
+            //币种验证  统一为currencycode三字码
+            if (int.TryParse(_teamCurrency, out int currency)) _teamCurrency = setData.Find(x => x.Id == currency)?.Name ?? "";
 
+            var costContents = new List<GroupCostAuditView>();
+            var subFeeTypeIds = new int[] { 
+                4, // 保险 82
+                5, // 机票 85
+            };
+            if (!subFeeTypeIds.Contains(feeType))
+            {
                 string costContentSql = $"Select * From Grp_GroupCost";
                 costContents = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == diId).ToList();
 
@@ -88,7 +99,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     }
                 }
             }
-            
+
             if (feeType == 1)
             {
                 //1089	对冲账或其他 不在审核范围
@@ -289,71 +300,71 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                     //车费 91
                     var opCarCost = item.FirstOrDefault(x => x.SId == 91);
-                    if (opCarCost != null) 
+                    if (opCarCost != null)
                         if (opCarCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.CarFee) * _opPayPercentage) isAutoAudit = false;
                     //982 车超时费 -- 暂无
                     //92  导游费
                     var opGuideCost = item.FirstOrDefault(x => x.SId == 92);
-                    if (opGuideCost != null) 
+                    if (opGuideCost != null)
                         if (opGuideCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideFee) * _opPayPercentage) isAutoAudit = false;
                     //94  导游景点费
                     var opGuideScenicCost = item.FirstOrDefault(x => x.SId == 94);
-                    if (opGuideScenicCost != null) 
+                    if (opGuideScenicCost != null)
                         if (opGuideScenicCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideScenicFee) * _opPayPercentage) isAutoAudit = false;
                     //95  导游小费
                     var opGuideTipCost = item.FirstOrDefault(x => x.SId == 95);
-                    if (opGuideTipCost != null) 
+                    if (opGuideTipCost != null)
                         if (opGuideTipCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideTipFee) * _opPayPercentage) isAutoAudit = false;
                     //983 导游餐补
                     var opGuideMealCost = item.FirstOrDefault(x => x.SId == 983);
-                    if (opGuideMealCost != null) 
+                    if (opGuideMealCost != null)
                         if (opGuideMealCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideMealFee) * _opPayPercentage) isAutoAudit = false;
                     //984 导游房补
                     var opGuideRoomCost = item.FirstOrDefault(x => x.SId == 984);
-                    if (opGuideRoomCost != null) 
+                    if (opGuideRoomCost != null)
                         if (opGuideRoomCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideRoomFee) * _opPayPercentage) isAutoAudit = false;
                     //985 导游交通
                     var opGuideTrafficCost = item.FirstOrDefault(x => x.SId == 985);
-                    if (opGuideTrafficCost != null) 
+                    if (opGuideTrafficCost != null)
                         if (opGuideTrafficCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideTrafficFee) * _opPayPercentage) isAutoAudit = false;
                     //96  接送机费 -- 暂无
                     //97  其他费用 -- 暂无
                     //979 司机工资
                     var opDriverCost = item.FirstOrDefault(x => x.SId == 979);
-                    if (opDriverCost != null) 
+                    if (opDriverCost != null)
                         if (opDriverCost.Price * _opRate > _teamRate * _opPayPercentage * opCostInfo.Sum(x => x.DriverFee) * _opPayPercentage) isAutoAudit = false;
                     //980 司机小费
                     var opDriverTipCost = item.FirstOrDefault(x => x.SId == 980);
-                    if (opDriverTipCost != null) 
+                    if (opDriverTipCost != null)
                         if (opDriverTipCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.DriverTipFee) * _opPayPercentage) isAutoAudit = false;
                     //981 司机餐补
                     var opDriverMealCost = item.FirstOrDefault(x => x.SId == 981);
-                    if (opDriverMealCost != null) 
+                    if (opDriverMealCost != null)
                         if (opDriverMealCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.DriverMealFee) * _opPayPercentage) isAutoAudit = false;
                     //988 客户早餐费用
                     var opClientBreakfastCost = item.FirstOrDefault(x => x.SId == 988);
-                    if (opClientBreakfastCost != null) 
+                    if (opClientBreakfastCost != null)
                         if (opClientBreakfastCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ClientBreakfastFee) * _opPayPercentage) isAutoAudit = false;
                     //93  客户午餐费用
                     var opClientLunchCost = item.FirstOrDefault(x => x.SId == 93);
-                    if (opClientLunchCost != null) 
+                    if (opClientLunchCost != null)
                         if (opClientLunchCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ClientLunchFee) * _opPayPercentage) isAutoAudit = false;
                     //989 客户晚餐费用
                     var opClientDinnerCost = item.FirstOrDefault(x => x.SId == 989);
-                    if (opClientDinnerCost != null) 
+                    if (opClientDinnerCost != null)
                         if (opClientDinnerCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ClientDinnerFee) * _opPayPercentage) isAutoAudit = false;
                     //990 景点门票费
                     var opScenicTicketCost = item.FirstOrDefault(x => x.SId == 990);
-                    if (opScenicTicketCost != null) 
+                    if (opScenicTicketCost != null)
                         if (opScenicTicketCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ScenicTicketFee) * _opPayPercentage) isAutoAudit = false;
                     //991 饮料/零食/水果
                     var opDrinkSnackFruitCost = item.FirstOrDefault(x => x.SId == 991);
-                    if (opDrinkSnackFruitCost != null) 
+                    if (opDrinkSnackFruitCost != null)
                         if (opDrinkSnackFruitCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.DrinkSnackFruitFee) * _opPayPercentage) isAutoAudit = false;
                     //992 住补费用 -- 暂无
                     //994 翻译费
                     var opTranslatorCost = item.FirstOrDefault(x => x.SId == 994);
-                    if (opTranslatorCost != null) 
+                    if (opTranslatorCost != null)
                         if (opTranslatorCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.TranslatorFee) * _opPayPercentage) isAutoAudit = false;
                     //1059    导游超时费用 -- 暂无
                     //1070    尾款金额 -- 暂无
@@ -397,9 +408,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                 var isAutoAudit = false;
                 var currModule = 98; //其他款项
-                int groupSize = 0; // 团组人数
-                var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).FirstAsync();
-                if (groupDetails != null) groupSize = groupDetails.VisitPNumber;
+                int groupSize =  groupDetails.VisitPNumber;
 
                 decimal otherSubTotal = costContents.Sum(x => x.TeFee);
                 decimal groupCostCNYTotal = costContents.Sum(x => x.TeFee) * _teamRate * groupSize; //团组成本出行物资总金额
@@ -496,13 +505,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             {
                 #region 保险费用录入自动审核
                 var currModule = 82;
-                var groupDetails = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).First(); 
-                if (groupDetails == null)
-                {
-                    _view.Msg = $"团组信息为空,不可自动审核!";
-                    return _view;
-                }
-
                 var insuranceCountryCostData = _sqlSugar.Queryable<Res_BasicInsuranceCost>().Where(x => x.IsDel == 0).ToList();
                 if (!insuranceCountryCostData.Any())
                 {
@@ -601,11 +603,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                 //自动审核
                 var ccpUpdate = _sqlSugar.Updateable<Grp_CreditCardPayment>()
-                                      .SetColumns(it => it.IsAuditGM == 3)
-                                      .SetColumns(it => it.AuditGMOperate == 4)
-                                      .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
-                                      .Where(s => s.DIId == diId && s.CTable == currModule && s.CId == dataId)
-                                      .ExecuteCommand();
+                    .SetColumns(it => it.IsAuditGM == 3)
+                    .SetColumns(it => it.AuditGMOperate == 4)
+                    .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                    .Where(s => s.DIId == diId && s.CTable == currModule && s.CId == dataId)
+                    .ExecuteCommand();
                 if (ccpUpdate > 0)
                 {
                     _view.Code = 200;
@@ -615,6 +617,148 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 return _view;
                 #endregion
             }
+            else if (feeType == 5)
+            {
+                #region 机票费用自动审核只处理舱位相关的费用
+
+                var currModule = 85;
+                var auditFeeTypeIds = new List<int>() {
+                    457,   //头等舱
+                    458,   //公务舱
+                    459,   //超经舱
+                    460,   //经济舱
+                    1430,  //公务舱(实际经济舱)
+                    1431,  //头等舱(实际公务舱)
+                    1432,  //头等舱(实际经济舱)
+                };
+
+                var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
+                    .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
+                    .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
+                    .Select((x,y) => new { 
+                        x.Id,
+                        CcpId = y.Id,
+                        x.Price,
+                        x.CType,
+                        x.ClientNum,
+                        x.DIId
+                    })
+                    .FirstAsync();
+                if (airInfo == null)
+                {
+                    _view.Msg = $"机票信息为空或费用类型不在自动审核范围内,不可自动审核!";
+                    return _view;
+                }
+
+                //团组成本 经济舱、头等舱、公务舱
+                int ecoPaxCount = groupInfo.JJCRS,   //经济舱人数
+                    firstClassCnt = groupInfo.TDCRS, //头等舱人数
+                    bizClassCnt = groupInfo.GWCRS;   //公务舱人数
+                decimal ecoCost = groupInfo.JJCCB,   //经济舱成本费用
+                        firstCost = groupInfo.TDCCB, //头等舱成本费用
+                        bizCost = groupInfo.GWCCB;   //公务舱成本费用
+                decimal ecoTotalCost = ecoPaxCount * ecoCost,       //经济舱成本费用合计
+                        firstTotalCost = firstClassCnt * firstCost, //头等舱成本费用合计
+                        bizTotalCost = bizClassCnt * bizCost;       //公务舱成本费用合计
+
+                int currAirType = airInfo.CType; //当前舱位类型
+                int currAirTypeCnt = 0;          //当前舱位人数
+                //decimal currAirFee = 0.00M;      //当前舱位录入费用
+                decimal currAirCost = 0.00M;     //当前舱位成本费用
+
+
+                switch (airInfo.CType)
+                {
+                    //头等舱
+                    case 457:
+                        currAirTypeCnt = groupInfo.TDCRS; //头等舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.TDCCB; //头等舱成本费用合计
+                        break;
+                    //公务舱
+                    case 458:
+                        currAirTypeCnt = groupInfo.GWCRS; //公务舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.GWCCB; //公务舱成本费用合计
+                        break;
+                    case 459: //超经舱
+                        currAirTypeCnt = groupInfo.JJCRS; //经济舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.JJCCB; //经济舱成本费用合计
+                        break;
+                    case 460: //经济舱
+                        currAirTypeCnt = groupInfo.JJCRS; //经济舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.JJCCB; //经济舱成本费用合计
+                        break;
+                    case 1430: //公务舱(实际经济舱)
+                        currAirTypeCnt = groupInfo.GWCRS; //公务舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.GWCCB; //公务舱成本费用合计
+                        break;
+                    case 1431: //头等舱(实际公务舱)
+                        currAirTypeCnt = groupInfo.TDCRS; //头等舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.TDCCB; //头等舱成本费用合计
+                        break;
+                    case 1432: //头等舱(实际经济舱)
+                        currAirTypeCnt = groupInfo.TDCRS; //头等舱人数
+                        currAirCost = currAirTypeCnt * groupInfo.TDCCB; //头等舱成本费用合计
+                        break;
+                    default:
+                        _view.Msg = $"机票费用类型不在自动审核范围内,不可自动审核!";
+                        return _view;
+                }
+
+                var currAirTypeDatas = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
+                    .Where(x => x.IsDel == 0 && x.DIId == diId && x.CType == airInfo.CType && x.ClientNum == currAirTypeCnt)
+                    .ToListAsync();
+                var airTypeText = airInfo.CType switch
+                {
+                    457 => "头等舱",
+                    458 => "公务舱",
+                    459 => "超经舱",
+                    460 => "经济舱",
+                    1430 => "公务舱(实际经济舱)",
+                    1431 => "头等舱(实际公务舱)",
+                    1432 => "头等舱(实际经济舱)",
+                    _ => "未知舱位"
+                };
+
+                if (!currAirTypeDatas.Any())
+                {
+                    _view.Msg = $"{airTypeText}机票费用数据未填写,不可自动审核!";
+                    return _view;
+                }
+
+                //验证费用类型
+                if (!currAirTypeDatas.Any(x => x.Id == airInfo.CcpId))
+                {
+                    _view.Msg = $"机票费用({airTypeText})超出团组成本费用";
+                    return _view;
+                }
+
+                //验证是否超出头等舱成本费用
+                decimal currAirTypeFee = currAirTypeDatas.Sum(x => x.Price * x.ClientNum);
+                if (currAirTypeFee > currAirCost)
+                {
+                    _view.Msg = $"机票费用({airTypeText})超出团组成本费用";
+                    QuashAudit(currModule, diId, currAirTypeDatas.Select(x => x.Id).ToArray());
+                    return _view;
+                }
+
+                //执行自动审核及相关字段更改
+                var upd = _sqlSugar.Updateable<Grp_CreditCardPayment>()
+                    .SetColumns(x => x.IsAuditGM == 3)
+                    .SetColumns(x => x.AuditGMOperate == 4)
+                    .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                    .Where(x => x.Id == airInfo.CcpId)
+                    .ExecuteCommand();
+                if (upd > 0)
+                {
+                    _view.Code = StatusCodes.Status200OK;
+                    _view.Msg = "自动审核执行成功";
+                    return _view;
+                }
+                _view.Msg = "自动审核执行失败";
+                return _view;
+
+                #endregion
+            }
             else _view.Msg = $"请传入有效的feeType参数";
 
             return _view;
@@ -625,7 +769,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// </summary>
         /// <param name="type">
         /// 酒店 76
-        /// op   79
+        /// op 79
         /// </param>
         /// <param name="diId"></param>
         /// <param name="dataId"></param>
@@ -653,7 +797,43 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return false;
         }
 
-        //
+
+        /// <summary>
+        /// air 撤销自动审核的数据
+        /// </summary>
+        /// <param name="type">
+        /// 机票
+        /// </param>
+        /// <param name="diId"></param>
+        /// <param name="dataId"></param>
+        /// <returns></returns>
+        private bool QuashAudit(int type, int diId, int[] dataId)
+        {
+            //撤销该条数据的自动审核 --> 该条数据的审核状态是自动审核  3 --> 0
+            var ccpInfos = _sqlSugar.Queryable<Grp_CreditCardPayment>()
+                .Where(s => s.DIId == diId && s.CTable == type && dataId.Contains(s.CId) && s.IsAuditGM == 3)
+                .ToList();
+            if (ccpInfos.Any())
+            {
+                ccpInfos.ForEach(x =>
+                {
+                    x.IsAuditGM = 0;
+                    x.AuditGMOperate = 0;
+                    x.AuditGMDate = string.Empty;
+                });
+
+                var ccpUpd = _sqlSugar.Updateable(ccpInfos)
+                    .UpdateColumns(x => new { x.IsAuditGM, x.AuditGMOperate, x.AuditGMDate })
+                    .ExecuteCommand();
+                if (ccpUpd > 0)
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
         /// <summary>
         /// 费用自动审核
         /// </summary>

+ 51 - 0
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -1432,6 +1432,17 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                         }
                     }
                 }
+
+                //权限前台验证
+                var auditPers = new List<GoodsStorageAuditPerView>
+                {
+                    new() { AuditPer = true, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr_Reception.GetDescription() }
+                };
+                if (_goodsTypeIds.Contains(item.GoodsTypeId))
+                {
+                    auditPers.Add(new() { AuditPer = true, AuditDep = GoodsAuditDepEnum.Hr, ButtonText = GoodsAuditDepEnum.Hr.GetDescription() });
+                }
+                item.AuditPers = auditPers.ToArray();
             }
 
             if (dto.PortType == 2 || dto.PortType == 3)
@@ -3024,6 +3035,42 @@ FROM
                 .WhereIF(!string.IsNullOrEmpty(goodsName), x => x.GoodsName.Contains(goodsName))
                 .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
+            //普通物品领用审核模板
+            var normAuditTemps = await _approvalProcessRep.GetTemplateByBusinessTypeAsync(2); //普通物品
+
+            var normAuditUsers = new List<GoodsStorageAuditPerView>();
+            normAuditTemps?.TempNodes.ForEach(x =>
+            {
+                var auditDep = GoodsAuditDepEnum.Hr_Reception;
+                if (x.NodeName.Contains("人事部主管/经理审核")) auditDep = GoodsAuditDepEnum.Hr;
+                else if (x.NodeName.Contains("前台审核")) auditDep = GoodsAuditDepEnum.Hr;
+                x.NodeUsers.ForEach(y =>
+                {
+                    var userFlang = false;
+                    if (y.UserId == currUserId) userFlang = true;
+                    var info = new GoodsStorageAuditPerView() { ButtonText = x.NodeName, AuditDep = auditDep, AuditPer = userFlang };
+                    normAuditUsers.Add(info);
+                });
+            });
+
+            //贵重物品领用审核模板
+            var valuableAuditTemps = await _approvalProcessRep.GetTemplateByBusinessTypeAsync(2); //贵重物品
+            var valuableAuditUsers = new List<GoodsStorageAuditPerView>();
+            valuableAuditTemps?.TempNodes.ForEach(x =>
+            {
+                var auditDep = GoodsAuditDepEnum.Hr_Reception;
+                if (x.NodeName.Contains("人事部主管/经理审核")) auditDep = GoodsAuditDepEnum.Hr;
+                else if (x.NodeName.Contains("前台审核")) auditDep = GoodsAuditDepEnum.Hr_Reception;
+                x.NodeUsers.ForEach(y =>
+                {
+                    var userFlang = false;
+                    if (y.UserId == currUserId) userFlang = true;
+                    var info = new GoodsStorageAuditPerView() { ButtonText = x.NodeName, AuditDep = auditDep, AuditPer = userFlang };
+                    valuableAuditUsers.Add(info);
+                });
+            });
+
+
             foreach (var item in view)
             {
                 var details = $"暂无物品信息数据";
@@ -3093,6 +3140,10 @@ FROM
                     });
                     item.StatusDesc = text.ToString();
                 }
+
+                //权限前台验证
+                if (item.IsValuable) item.AuditPers = valuableAuditUsers.ToArray();
+                else item.AuditPers = normAuditUsers.ToArray();
             }
 
             if (dto.PortType == 2 || dto.PortType == 3)