Browse Source

扩展审核状态,增加自动审核逻辑

在 `Fin_DailyFeePayment.cs` 中,`MAudit` 和 `FAudit` 属性的注释中添加了“3 自动审核”选项。
在 `Fin_DailyFeePaymentView.cs` 中,增加了对 `FAudit` 为 3 的条件处理。
在 `DailyFeePaymentRepository.cs` 中,新增了 `auditStatusData` 列表,包含不同的审核状态选项。
添加了 `GMAutoApprovalType` 方法以验证自动审核类型,并在相关逻辑中调用。
修改了费用审核逻辑,确保在特定条件下自动审核通过。
更新了编辑费用的逻辑,确保已审核的数据不可编辑,并根据审核状态进行处理。
移除了部分注释,简化了代码,提升了逻辑的清晰性和可读性。
LEIYI 2 days ago
parent
commit
93371798dc

+ 2 - 2
OASystem/OASystem.Domain/Entities/Financial/Fin_DailyFeePayment.cs

@@ -26,7 +26,7 @@ namespace OASystem.Domain.Entities.Financial
 
         /// <summary>
         /// 总经理审核
-        /// 0 未审核 1 审核通过 2 审核未通过
+        /// 0 未审核 1 审核通过 2 审核未通过 3 自动审核
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int MAudit { get; set; }
@@ -39,7 +39,7 @@ namespace OASystem.Domain.Entities.Financial
 
         /// <summary>
         /// 财务主管审核
-        /// 0 未审核 1 审核通过 2 审核未通过
+        /// 0 未审核 1 审核通过 2 审核未通过 3 自动审核
         /// </summary>
         [SugarColumn(IsNullable = true,ColumnDataType = "int")]
         public int FAudit { get; set; }

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

@@ -106,6 +106,11 @@ namespace OASystem.Domain.ViewModels.Financial
                     str = "未通过";
                     FAuditName = "朱成梅";
                 }
+                else if (FAudit == 3)
+                {
+                    str = "自动审核";
+                    FAuditName = "管理员";
+                }
                 return str;
             }
         }

+ 64 - 74
OASystem/OASystem.Infrastructure/Repositories/Financial/DailyFeePaymentRepository.cs

@@ -117,11 +117,22 @@ namespace OASystem.Infrastructure.Repositories.Financial
                                       
             }                         
             var userData1 = userData.Select(x => new { x.Id, x.CnName }).ToList();
+
             //62 公转 63 私转        
             var feeMarkTypeData = setTypeData.Where(s => s.Id == 62 || s.Id == 63).ToList();
             var feeMarkSubTypeData = setData.Where(s => s.STid == 62 || s.STid == 63).ToList();
             var companyNameData = await _CompanyRep.GetCompanyNameData();
 
+            //审核状态
+            var auditStatusData = new List<dynamic>()
+            {
+                new { Id = -1, Name = "全部" },
+                new { Id = 0, Name = "未审核" },
+                new { Id = 1, Name = "已审核" },
+                new { Id = 2, Name = "审核未通过" },
+                new { Id = 3, Name = "自动审核" }
+            };
+
             if (dto.PortType == 1) //web
             {
                 DailyFeePaymentList = new 
@@ -131,7 +142,8 @@ namespace OASystem.Infrastructure.Repositories.Financial
                     UserNameData = userData1,
                     FeeMarkTypeData = feeMarkTypeData,
                     FeeMarkSubTypeData = feeMarkSubTypeData,
-                    CompanyNameData = companyNameData.Data
+                    CompanyNameData = companyNameData.Data,
+                    AuditStatusData = auditStatusData
                 };
             }
             else if (dto.PortType == 2) //安卓
@@ -149,9 +161,43 @@ namespace OASystem.Infrastructure.Repositories.Financial
             result.Msg = "查询成功!";
             result.Data = DailyFeePaymentList;
             return result;
+        }
+
+        /// <summary>
+        /// 总经理自动审核通过类型 
+        /// 90 Parent 各部门基础固定费用明细  
+        /// 104 Parent 团组费用
+        /// 672 Sub 办公费用-信息部申请费用
+        /// </summary>
+        /// <param name="typeId"></param>
+        /// <returns></returns>
+        public async Task<bool> GMAutoApprovalType(int typeId)
+        {
+            if (typeId < 1) return false;
+
+            var parentIds = new List<int>() 
+                {   
+                    90,  // 各部门基础固定费用明细
+                    104, // 团组费用
+                };
+            var subIds = new List<int>()
+                {
+                    672, //办公费用-信息部申请费用
+                };
+
+            var parentTypeDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && parentIds.Contains(x.STid)).ToListAsync();
+            var subTypeDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && subIds.Contains(x.Id)).ToListAsync();
 
+            var typeDatas = new List<Sys_SetData>();
+            if (parentTypeDatas.Any()) typeDatas.AddRange(parentTypeDatas);
+            if (subTypeDatas.Any()) typeDatas.AddRange(subTypeDatas);
+
+            if (typeDatas.Any(x => x.Id == typeId)) return true;
+
+            return false;
         }
 
+
         /// <summary>
         /// 日付申请查询 使用的数据源
         /// </summary>
@@ -248,17 +294,8 @@ namespace OASystem.Infrastructure.Repositories.Financial
                     var setData = _setDataTypeRep.QueryDto<Sys_SetData, SetDataView>(s => s.STid == dto.FeeTypeId).ToList();
                     if (setData.Count > 0)
                     {
-                        string setDataIds = "";
-                        foreach (var item in setData)
-                        {
-                            setDataIds += item.Id + ",";
-                        }
-
-                        if (setDataIds.Length > 0)
-                        {
-                            setDataIds = setDataIds.Substring(0, setDataIds.Length - 1);
-                            sqlWhere += string.Format(" And dfp.PriceTypeId In ({0})", setDataIds);
-                        }
+                        string setDataIds = string.Join(",", setData.Select(x => x.Id).ToList());
+                        sqlWhere += string.Format(" And dfp.PriceTypeId In ({0})", setDataIds);
                     }
                 }
             }
@@ -269,7 +306,6 @@ namespace OASystem.Infrastructure.Repositories.Financial
             if (dto.CreateUserId != -1)
                 sqlWhere += string.Format(" And dfp.CreateUserId = {0}", dto.CreateUserId);
 
-
             int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
             int endIndex = startIndex + dto.PageSize - 1;
 
@@ -382,39 +418,11 @@ namespace OASystem.Infrastructure.Repositories.Financial
             _fee.CreateUserId = dto.UserId;
             _fee.GroupId = dto.GroupId;
 
-            /*
-             * 2024-10-29
-             * 各部门基础固定费用明细”里的费用数据新增后,财务和总经理审核都默认直接通过isAudit=1),并且可编辑,如果ispay=1的话将不可编辑
-             * 2025-02-24
-             * 团组费用 默认总经理审核通过
-             * 2025-03-25
-             * 各部门基础固定费用明细”里的费用数据新增后,默认老张通过 财务手动审核 
-             * 
-             */
+            //自动审核验证
+            var auditPer  = await GMAutoApprovalType(dto.PriceTypeId);
             var priceTypeInfo = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.IsDel == 0 && x.Id == dto.PriceTypeId);
-            if (priceTypeInfo != null && (priceTypeInfo.STid == 90 || priceTypeInfo.STid == 104))
+            if (auditPer)
             {
-
-                //费用类型为团组费用时 验证groupId
-                if (priceTypeInfo.STid == 104)
-                {
-                    var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == _fee.GroupId);
-                    if (groupInfo == null)
-                    {
-                        _sqlSugar.RollbackTran();
-
-                        result.Msg = $"请选择有效的团组名称!";
-                        return result;
-                    }
-                }
-
-
-                //if (priceTypeInfo.STid == 90)
-                //{
-                //    _fee.FAudit = 1;
-                //    _fee.FAuditDate = DateTime.Now;
-                //}
-
                 _fee.MAudit = 1;
                 _fee.MAuditDate = DateTime.Now;
             }
@@ -451,28 +459,25 @@ namespace OASystem.Infrastructure.Repositories.Financial
         {
             Result result = new Result() { Code = -2 };
 
+            //自动审核验证
+            var auditPer = await GMAutoApprovalType(dto.PriceTypeId);
+
             #region 已审核的数据不可编辑
             var dailyFeeInfo = await _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(it => it.Id == dto.Id && it.IsDel == 0).FirstAsync();
             if (dailyFeeInfo != null)
             {
-                if (dailyFeeInfo.FAudit == 1 || dailyFeeInfo.MAudit == 1)
+                var auditIds = new List<int>() { 1, 3 };
+
+                if (auditIds.Contains(dailyFeeInfo.FAudit) || auditIds.Contains(dailyFeeInfo.MAudit))
                 {
-                    var setData = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.IsDel == 0 && x.Id == dto.PriceTypeId);
-                    if (setData != null)
+                    if (auditPer)
                     {
-                        if (setData.STid == 90 || setData.STid == 104)
+                        if (dailyFeeInfo.IsPay == 1)
                         {
-                            if (dailyFeeInfo.IsPay == 1)
-                            {
-                                result.Msg = "该笔费用已付款,不可修改!";
-                                return result;
-                            }
-                        }
-                        else
-                        {
-                            result.Msg = "审核已通过,不可修改!";
+                            result.Msg = "该笔费用已付款,不可修改!";
                             return result;
                         }
+
                     }
                     else
                     {
@@ -489,21 +494,6 @@ namespace OASystem.Infrastructure.Repositories.Financial
             {
                 Fin_DailyFeePayment _fee = _mapper.Map<Fin_DailyFeePayment>(dto);
 
-                /*
-                 * 
-                 * 2025-02-24
-                 * 更改后的费用类型为 团组费用 默认总经理审核通过
-                 * 2025-03-25
-                 * 更改后的费用类型为 各部门基础固定费用明细”里的费用数据新增后,默认老张通过 财务手动审核
-                 * 
-                 */
-                var priceTypeInfo = await _sqlSugar.Queryable<Sys_SetData>().FirstAsync(x => x.IsDel == 0 && x.Id == dto.PriceTypeId);
-                var auditStatus = false;
-                if (priceTypeInfo != null && (priceTypeInfo.STid == 90 || priceTypeInfo.STid == 104))
-                {
-                    auditStatus = true;
-                }
-
                 _fee.CreateUserId = dto.UserId;
                 int? editFeeStatus = await _sqlSugar.Updateable<Fin_DailyFeePayment>()
                     .SetColumns(a => new Fin_DailyFeePayment
@@ -515,8 +505,8 @@ namespace OASystem.Infrastructure.Repositories.Financial
                         CompanyId = dto.CompanyId,
                         GroupId = dto.GroupId,
                     })
-                    .SetColumnsIF(auditStatus, a => a.MAudit == 1)
-                    .SetColumnsIF(auditStatus, a => a.MAuditDate == DateTime.Now)
+                    .SetColumnsIF(auditPer, a => a.MAudit == 3)
+                    .SetColumnsIF(auditPer, a => a.MAuditDate == DateTime.Now)
                     .Where(a => a.Id == dto.Id)
                     .ExecuteCommandAsync();